euclidean ($Date: 2008/21/04 $)
index
/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap_v0.1/euclidean.py

Euclidean is a collection of python utilities for complex numbers, paths, polygons & Vec3s.
 
To use euclidean, install python 2.x on your machine, which is avaliable from http://www.python.org/download/
 
Then in the folder which euclidean is in, type 'python' in a shell to run the python interpreter.  Finally type
'import euclidean' to import these utilities and 'from vec3 import Vec3' to import the Vec3 class.
 
 
Below are examples of euclidean use.
 
>>> from euclidean import *
>>> from vec3 import Vec3
>>> origin=Vec3()
>>> right=Vec3(1.0,0.0,0.0)
>>> back=Vec3(0.0,1.0,0.0)
>>> getAngleAroundZAxisDifference(back, right)
1.5707963267948966
>>> getPointMaximum(right,back)
1.0, 1.0, 0.0
>>> polygon=[origin, right, back]
>>> getPolygonLength(polygon)
3.4142135623730949
>>> getPolygonArea(polygon)
0.5

 
Modules
       
math

 
Classes
       
Endpoint
SurroundingLoop
XIntersection

 
class Endpoint
    The endpoint of a segment.
 
  Methods defined here:
__repr__(self)
Get the string representation of this Endpoint.
getFromOtherPoint(self, otherEndpoint, point)
Initialize from other endpoint.
getHop(self, layerFillInset, path)
Get a hop away from the endpoint if the other endpoint is doubling back.
getNearestEndpoint(self, endpoints)
Get nearest endpoint.
getNearestMiss(self, arounds, endpoints, extrusionWidth, path, paths, stretchedXSegments)
Get the nearest endpoint which the segment to that endpoint misses the other extrusions.
isPointIntersectingSegments(self, extrusionWidth, inputPoint, paths, segmentYMirror, stretchedXSegments)
Determine if the segment to the point is crossing a stretched x segment.

 
class SurroundingLoop
    A loop that surrounds paths.
 
  Methods defined here:
__init__(self)
__repr__(self)
Get the string representation of this surrounding loop.
addToThreads(self, oldOrderedLocation, skein)
Add to paths from the last location.
getFillLoops(self)
Get last fill loops from the outside loop and the loops inside the inside loops.
getFromInsideSurroundings(self, extrusionWidth, inputSurroundingInsides)
Initialize from inside surrounding loops.
getLoopsToBeFilled(self)
Get last fill loops from the outside loop and the loops inside the inside loops.
transferPaths(self, paths)
Transfer paths.

 
class XIntersection
    A class to hold the x intersection position and the number of the loop which intersected.
 
  Methods defined here:
__cmp__(self, other)
Get comparison in order to sort x intersections in ascending order of x.
__repr__(self)
Get the string representation of this x intersection.
getFromIndexX(self, index, x)
Get the bounding loop from a path.

 
Functions
       
addSurroundingLoopBeginning(loop, skein)
Add surrounding loop beginning to gcode output.
addToThreadsFromLoop(extrusionHalfWidthSquared, gcodeType, loop, oldOrderedLocation, skein)
Add to threads from the last location from loop.
addToThreadsRemoveFromSurroundings(oldOrderedLocation, surroundingLoops, skein)
Add to threads from the last location from surrounding loops.
addXIntersections(loop, solidIndex, xIntersectionList, y)
Add the x intersections for a loop.
addXIntersectionsFromLoopLists(loopLists, solidXIntersectionList, y)
Add the x intersections for the loop lists.
addXIntersectionsFromLoops(loops, solidIndex, xIntersectionList, y)
Add the x intersections for the loops.
getAngleAroundZAxisDifference(subtractFromVec3, subtractVec3)
Get the angle around the Z axis difference between a pair of Vec3s.
 
Keyword arguments:
subtractFromVec3 -- Vec3 whose angle will be subtracted from
subtractVec3 -- Vec3 whose angle will be subtracted
getAroundLoop(begin, end, loop)
Get an arc around a loop.
getAwayPath(path, radius)
Get a loop with only the points that are far enough away from each other.
getComplexCrossProduct(firstComplex, secondComplex)
Get z component cross product of a pair of complexes.
getComplexDot(firstComplex, secondComplex)
Get the dot product of a pair of complexes.
getComplexMaximum(firstComplex, secondComplex)
Get a complex with each component the maximum of the respective components of a pair of complexes.
getComplexMaximumFromVec3List(vec3List)
Get a complex with each component the maximum of the respective components of a list of Vec3s.
getComplexMinimum(firstComplex, secondComplex)
Get a complex with each component the minimum of the respective components of a pair of complexes.
getComplexMinimumFromVec3List(vec3List)
Get a complex with each component the minimum of the respective components of a list of Vec3s.
getDistanceSquaredToPlaneSegment(segmentBegin, segmentEnd, point)
Get the distance squared from a point to the x & y components of a segment.
getFillOfSurroundings(surroundingLoops)
Get extra fill loops of surrounding loops.
getHalfSimplifiedLoop(loop, radius, remainder)
Get the loop with half of the points inside the channel removed.
getInsidesAddToOutsides(loops, outsides)
Add loops to either the insides or outsides.
getLeftPoint(path)
Get the leftmost point in the path.
getMaximumSpan(loop)
Get the maximum span in the xy plane.
getNearestDistanceSquaredIndex(point, loop)
Get the distance squared to the nearest segment of the loop and index of that segment.
getNearestPathDistanceSquaredIndex(point, path)
Get the distance squared to the nearest segment of the path and index of that segment.
getNearestPointOnSegment(segmentBegin, segmentEnd, point)
getNumberOfIntersectionsToLeft(leftPoint, loop)
Get the number of intersections through the loop for the line starting from the left point and going left.
getOrderedSurroundingLoops(extrusionWidth, surroundingLoops)
Get ordered surrounding loops from surrounding loops.
getPathLength(path)
Get the length of a path ( an open polyline ).
getPathRoundZAxisByPlaneAngle(planeAngle, path)
Get Vec3 array rotated by a plane angle.
 
Keyword arguments:
planeAngle - plane angle of the rotation
path - Vec3 array whose rotation will be returned
getPlaneDot(vec3First, vec3Second)
Get the dot product of the x and y components of a pair of Vec3s.
getPlaneDotPlusOne(vec3First, vec3Second)
Get the dot product plus one of the x and y components of a pair of Vec3s.
getPointMaximum(firstPoint, secondPoint)
Get a point with each component the maximum of the respective components of a pair of Vec3s.
getPointMinimum(firstPoint, secondPoint)
Get a point with each component the minimum of the respective components of a pair of Vec3s.
getPointPlusSegmentWithLength(length, point, segment)
Get point plus a segment scaled to a given length.
getPolar(angle, radius)
Get polar complex from counterclockwise angle from 1, 0 and radius.
 
Keyword arguments:
angle -- counterclockwise angle from 1, 0
radius -- radius of complex
getPolygonArea(polygon)
Get the xy plane area of a polygon.
getPolygonLength(polygon)
Get the length of a polygon perimeter.
getRotatedClockwiseQuarterAroundZAxis(vector3)
Get vector3 rotated a quarter clockwise turn around Z axis.
getRotatedWiddershinsQuarterAroundZAxis(vector3)
Get Vec3 rotated a quarter widdershins turn around Z axis.
getRoundXAxis(angle, vector3)
Get Vec3 rotated around X axis from widdershins angle and Vec3.
 
Keyword arguments:
angle - widdershins angle from 1, 0
vector3 - Vec3 whose rotation will be returned
getRoundYAxis(angle, vector3)
Get Vec3 rotated around Y axis from widdershins angle and Vec3.
 
Keyword arguments:
angle - widdershins angle from 1, 0
vector3 - Vec3 whose rotation will be returned
getRoundZAxis(angle, vector3)
Get Vec3 rotated around Z axis from widdershins angle and Vec3.
 
Keyword arguments:
angle - widdershins angle from 1, 0
vector3 - Vec3 whose rotation will be returned
getRoundZAxisByPlaneAngle(planeAngle, vector3)
Get Vec3 rotated by a plane angle.
 
Keyword arguments:
planeAngle - plane angle of the rotation
vector3 - Vec3 whose rotation will be returned
getRoundedPoint(point)
Get point with each component rounded.
getRoundedToThreePlaces(number)
Get value rounded to three places as string.
getSegmentsFromIntersections(solidXIntersectionList, y, z)
Get endpoint segments from the intersections.
getSimplifiedLoop(loop, radius)
Get loop with points inside the channel removed.
getTransferClosestSurroundingLoop(oldOrderedLocation, remainingSurroundingLoops, skein)
Get and transfer the closest remaining surrounding loop.
getTransferredPaths(insides, loop)
Get transferred paths from inside paths.
getTransferredSurroundingLoops(insides, loop)
Get transferred paths from inside surrounding loops.
getWiddershinsDot(vec3First, vec3Second)
Get the magintude of the positive dot product plus one of the x and y components of a pair of Vec3s, with the reversed sign of the cross product.
getXIntersection(firstPoint, secondPoint, y)
Get where the line crosses y.
getZComponentCrossProduct(vec3First, vec3Second)
Get z component cross product of a pair of Vec3s.
isClose(overlapDistanceSquared, loop, pointIndex)
Determine if the the point close to another point on the loop.
isInsideOtherLoops(loopIndex, loops)
Determine if a loop in a list is inside another loop in that list.
isLargeSameDirection(inset, loop, requiredSize)
Determine if the inset is in the same direction as the loop and if the inset is as large as the required size.
isLineIntersectingInsideXSegment(segmentFirstX, segmentSecondX, vector3First, vector3Second, y)
Determine if the line is crossing inside the x segment.
isLoopIntersectingInsideXSegment(loop, segmentFirstX, segmentSecondX, segmentYMirror, y)
Determine if the loop is intersecting inside the x segment.
isLoopIntersectingLoops(loop, otherLoops)
Determine if the loop is intersecting other loops.
isLoopListIntersectingInsideXSegment(loopList, segmentFirstX, segmentSecondX, segmentYMirror, y)
Determine if the loop list is crossing inside the x segment.
isPathInsideLoop(loop, path)
Determine if a path is inside another loop.
isPathInsideLoops(loops, path)
Determine if a path is inside another loop in a list.
isSegmentCompletelyInX(segment, xFirst, xSecond)
Determine if the segment overlaps within x.
isWiddershins(polygon)
Determine if the polygon goes round in the widdershins direction.
isWithinChannel(channelRadius, pointIndex, loop)
Determine if the the point is within the channel between two adjacent points.
isXSegmentIntersectingPaths(paths, segmentFirstX, segmentSecondX, segmentYMirror, y)
Determine if a path list is crossing inside the x segment.
toggleHashtable(hashtable, key, value)
Toggle a hashtable between having and not having a key.
transferClosestFillLoop(extrusionHalfWidthSquared, oldOrderedLocation, remainingFillLoops, skein)
Transfer the closest remaining fill loop.
transferClosestPath(oldOrderedLocation, remainingPaths, skein)
Transfer the closest remaining path.
transferClosestPaths(oldOrderedLocation, remainingPaths, skein)
Transfer the closest remaining paths.
transferPathsToSurroundingLoops(paths, surroundingLoops)
Transfer paths to surrounding loops.

 
Data
        __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
__date__ = '$Date: 2008/21/04 $'
__license__ = 'GPL 3.0'

 
Author
        Enrique Perez (perez_enrique@yahoo.com)