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

Euclidean is a collection of python utilities for complex numbers, paths, polygons & Vector3s.

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 vector3 import Vector3' to import the Vector3 class.


Below are examples of euclidean use.

>>> from euclidean import *
>>> origin=complex()
>>> right=complex(1.0,0.0)
>>> back=complex(0.0,1.0)
>>> getMaximum(right,back)
1.0, 1.0
>>> polygon=[origin, right, back]
>>> getPolygonLength(polygon)
3.4142135623730949
>>> getPolygonArea(polygon)
0.5

 
Modules
       
__init__
math

 
Classes
       
DistanceIndex
Endpoint
LoopLayer
PathZ
RotatedLoopLayer
SurroundingLoop
XIntersectionIndex

 
class DistanceIndex
    A class to hold the distance and the index of the loop.
 
  Methods defined here:
__init__(self, distance, index)
__repr__(self)
Get the string representation of this distance index.

 
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, fillInset, path)
Get a hop away from the endpoint if the other endpoint is doubling back.
getNearestEndpoint(self, endpoints)
Get nearest endpoint.
getNearestMiss(self, endpoints, path, pixelTable, width)
Get the nearest endpoint which the segment to that endpoint misses the other extrusions.
getNearestMissCheckEndpointPath(self, endpoints, path, pixelTable, width)
Get the nearest endpoint which the segment to that endpoint misses the other extrusions, also checking the path of the endpoint.

 
class LoopLayer
    Loops with a z.
 
  Methods defined here:
__init__(self, z)
__repr__(self)
Get the string representation of this loop layer.

 
class PathZ
    Complex path with a z.
 
  Methods defined here:
__init__(self, z)
__repr__(self)
Get the string representation of this path z.

 
class RotatedLoopLayer
    A rotated layer.
 
  Methods defined here:
__init__(self, z)
__repr__(self)
Get the string representation of this rotated loop layer.
getCopyAtZ(self, z)
Get a raised copy.

 
class SurroundingLoop
    A loop that surrounds paths.
 
  Methods defined here:
__init__(self, threadSequence)
__repr__(self)
Get the string representation of this surrounding loop.
addPerimeterInner(self, oldOrderedLocation, skein)
Add to the perimeter and the inner island.
addToBoundary(self, vector3)
Add vector3 to boundary.
addToLoop(self, vector3)
Add vector3 to loop.
addToThreads(self, oldOrderedLocation, skein)
Add to paths from the last location. perimeter>inner >fill>paths or fill> perimeter>inner >paths
getFillLoops(self)
Get last fill loops from the outside loop and the loops inside the inside loops.
getFromInsideSurroundings(self, inputSurroundingInsides, perimeterWidth)
Initialize from inside surrounding loops.
getLoopsToBeFilled(self)
Get last fill loops from the outside loop and the loops inside the inside loops.
transferClosestFillLoops(self, oldOrderedLocation, skein)
Transfer closest fill loops.
transferInfillPaths(self, oldOrderedLocation, skein)
Transfer the infill paths.
transferPaths(self, paths)
Transfer paths.

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

 
Functions
       
addCircleToPixelTable(pixelTable, point)
Add circle to the pixel table.
addElementToListTable(element, key, listTable)
Add an element to the list table.
addElementToPixelList(element, pixelTable, x, y)
Add an element to the pixel list.
addElementToPixelListFromPoint(element, pixelTable, point)
Add an element to the pixel list.
addListToListTable(elementList, key, listTable)
Add a list to the list table.
addLoopToPixelTable(loop, pixelTable, width)
Add loop to the pixel table.
addPathToPixelTable(path, pixelTable, value, width)
Add path to the pixel table.
addPixelTableToPixelTable(fromPixelTable, intoPixelTable)
Add from pixel table to the into pixel table.
addPixelToPixelTable(pixelTable, value, x, y)
Add pixel to the pixel table.
addPixelToPixelTableWithSteepness(isSteep, pixelTable, value, x, y)
Add pixels to the pixel table with steepness.
addPointToPath(path, pixelTable, point, value, width)
Add a point to a path and the pixel table.
addSegmentToPixelTable(beginComplex, endComplex, pixelTable, shortenDistanceBegin, shortenDistanceEnd, width)
Add line segment to the pixel table.
addSurroundingLoopBeginning(distanceFeedRate, loop, z)
Add surrounding loop beginning to gcode output.
addToThreadsFromLoop(extrusionHalfWidth, 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.
addValueSegmentToPixelTable(beginComplex, endComplex, pixelTable, value, width)
Add line segment to the pixel table.
addXIntersectionIndexesFromLoop(frontOverWidth, loop, solidIndex, xIntersectionIndexLists, width, yList)
Add the x intersection indexes for a loop.
addXIntersectionIndexesFromLoopListsY(loopLists, xIntersectionIndexList, y)
Add the x intersection indexes for the loop lists.
addXIntersectionIndexesFromLoopY(loop, solidIndex, xIntersectionIndexList, y)
Add the x intersection indexes for a loop.
addXIntersectionIndexesFromLoops(frontOverWidth, loops, solidIndex, xIntersectionIndexLists, width, yList)
Add the x intersection indexes for a loop.
addXIntersectionIndexesFromLoopsY(loops, solidIndex, xIntersectionIndexList, y)
Add the x intersection indexes for the loops.
addXIntersectionIndexesFromSegment(index, segment, xIntersectionIndexList)
Add the x intersection indexes from the segment.
addXIntersectionIndexesFromSegments(index, segments, xIntersectionIndexList)
Add the x intersection indexes from the segments.
addXIntersectionIndexesFromXIntersections(index, xIntersectionIndexList, xIntersections)
Add the x intersection indexes from the XIntersections.
addXIntersections(loop, xIntersections, y)
Add the x intersections for a loop.
addXIntersectionsFromLoopForTable(loop, xIntersectionsTable, width)
Add the x intersections for a loop into a table.
addXIntersectionsFromLoops(loops, xIntersections, y)
Add the x intersections for the loops.
addXIntersectionsFromLoopsForTable(loops, xIntersectionsTable, width)
Add the x intersections for a loop into a table.
compareSegmentLength(endpoint, otherEndpoint)
Get comparison in order to sort endpoints in ascending order of segment length.
concatenateRemovePath(connectedPaths, pathIndex, paths, pixelTable, segments, width)
Get connected paths from paths.
getAngleAroundZAxisDifference(subtractFromVec3, subtractVec3)
Get the angle around the Z axis difference between a pair of Vector3s.
getAroundLoop(begin, end, loop)
Get an arc around a loop.
getAwayPoints(points, radius)
Get a path with only the points that are far enough away from each other.
getBackOfLoops(loops)
Get the back of the loops.
getClippedAtEndLoopPath(clip, loopPath)
Get a clipped loop path.
getClippedLoopPath(clip, loopPath)
Get a clipped loop path.
getConnectedPaths(paths, pixelTable, width)
Get connected paths from paths.
getCrossProduct(firstComplex, secondComplex)
Get z component cross product of a pair of complexes.
getDiagonalFlippedLoop(loop)
Get loop flipped over the dialogonal, in other words with the x and y swapped.
getDiagonalFlippedLoops(loops)
Get loops flipped over the dialogonal, in other words with the x and y swapped.
getDistanceToPlaneSegment(segmentBegin, segmentEnd, point)
Get the distance squared from a point to the x & y components of a segment.
getDotProduct(firstComplex, secondComplex)
Get the dot product of a pair of complexes.
getDotProductPlusOne(firstComplex, secondComplex)
Get the dot product plus one of the x and y components of a pair of Vector3s.
getEndpointFromPath(path, pathIndex)
Get endpoint segment from a path.
getEndpointsFromSegmentTable(segmentTable)
Get the endpoints from the segment table.
getEndpointsFromSegments(segments)
Get endpoints from segments.
getFillOfSurroundings(surroundingLoops)
Get extra fill loops of surrounding loops.
getFourSignificantFigures(number)
Get number rounded to four significant figures as a string.
getFrontOfLoops(loops)
Get the front of the loops.
getFrontOverWidthAddXListYList(front, loopLists, numberOfLines, xIntersectionIndexLists, width, yList)
Get the front over width and add the x intersection index lists and ylist.
getFrontOverWidthAddYList(front, numberOfLines, xIntersectionIndexLists, width, yList)
Get the front over width and add the x intersection index lists and ylist.
getHalfSimplifiedLoop(loop, radius, remainder)
Get the loop with half of the points inside the channel removed.
getHalfSimplifiedPath(path, radius, remainder)
Get the path with half of the points inside the channel removed.
getHorizontalSegmentListsFromLoopLists(alreadyFilledArounds, front, numberOfLines, rotatedFillLoops, width)
Get horizontal segment lists inside loops.
getIncrementFromRank(rank)
Get the increment from the rank which is 0 at 1 and increases by three every power of ten.
getInsidesAddToOutsides(loops, outsides)
Add loops to either the insides or outsides.
getIntermediateLocation(alongWay, begin, end)
Get the intermediate location between begin and end.
getIntersectionOfXIntersectionIndexes(totalSolidSurfaceThickness, xIntersectionIndexList)
Get x intersections from surrounding layers.
getIntersectionOfXIntersectionsTables(xIntersectionsTables)
Get the intersection of both XIntersections tables.
getJoinOfXIntersectionIndexes(xIntersectionIndexList)
Get joined x intersections from surrounding layers.
getLargestLoop(loops)
Get largest loop from loops.
getLeftPoint(points)
Get the leftmost complex point in the points.
getListTableElements(listTable)
Get all the element in a list table.
getLoopInsideContainingLoop(containingLoop, loops)
Get a loop that is inside the containing loop.
getLoopStartingNearest(extrusionHalfWidth, location, loop)
Add to threads from the last location from loop.
getMaximum(firstComplex, secondComplex)
Get a complex with each component the maximum of the respective components of a pair of complexes.
getMaximumFromPoints(points)
Get a complex with each component the maximum of the respective components of a list of complex points.
getMaximumSpan(loop)
Get the maximum span of the loop.
getMinimum(firstComplex, secondComplex)
Get a complex with each component the minimum of the respective components of a pair of complexes.
getMinimumFromPoints(points)
Get a complex with each component the minimum of the respective components of a list of complex points.
getMinimumFromVec3List(vec3List)
Get a complex with each component the minimum of the respective components of a list of Vector3s.
getNearestDistanceIndex(point, loop)
Get the distance squared to the nearest segment of the loop and index of that segment.
getNearestPointOnSegment(segmentBegin, segmentEnd, point)
Get the nearest point on the segment.
getNormalized(complexNumber)
Get the normalized complex.
getNumberOfIntersectionsToLeft(loop, point)
Get the number of intersections through the loops for the line starting from the left point and going left.
getNumberOfIntersectionsToLeftOfLoops(loops, point)
Get the number of intersections through the loop for the line starting from the left point and going left.
getOrderedSurroundingLoops(perimeterWidth, surroundingLoops)
Get ordered surrounding loops from surrounding loops.
getPathLength(path)
Get the length of a path ( an open polyline ).
getPathsFromEndpoints(endpoints, fillInset, pixelTable, width)
Get paths from endpoints.
getPlaneDot(vec3First, vec3Second)
Get the dot product of the x and y components of a pair of Vector3s.
getPointMaximum(firstPoint, secondPoint)
Get a point with each component the maximum of the respective components of a pair of Vector3s.
getPointMinimum(firstPoint, secondPoint)
Get a point with each component the minimum of the respective components of a pair of Vector3s.
getPointPlusSegmentWithLength(length, point, segment)
Get point plus a segment scaled to a given length.
getPointsRoundZAxis(planeAngle, points)
Get points rotated by the plane angle
getPolygonArea(polygonComplex)
Get the area of a complex polygon.
getPolygonLength(polygon)
Get the length of a polygon perimeter.
getRank(width)
Get the rank which is 0 at 1 and increases by three every power of ten.
getRotatedWiddershinsQuarterAroundZAxis(vector3)
Get Vector3 rotated a quarter widdershins turn around Z axis.
getRoundZAxisByPlaneAngle(planeAngle, vector3)
Get Vector3 rotated by a plane angle.
getRoundedPoint(point)
Get point with each component rounded.
getRoundedToDecimalPlaces(decimalPlaces, number)
Get number rounded to a number of decimal places.
getRoundedToDecimalPlacesString(decimalPlaces, number)
Get number rounded to a number of decimal places as a string.
getRoundedToThreePlaces(number)
Get number rounded to three places as a string.
getSegmentFromPath(path, pathIndex)
Get endpoint segment from a path.
getSegmentFromPoints(begin, end)
Get endpoint segment from a pair of points.
getSegmentsFromXIntersectionIndexes(xIntersectionIndexList, y)
Get endpoint segments from the x intersection indexes.
getSegmentsFromXIntersections(xIntersections, y)
Get endpoint segments from the x intersections.
getSimplifiedLoop(loop, radius)
Get loop with points inside the channel removed.
getSimplifiedLoops(loops, radius)
Get the simplified loops.
getSimplifiedPath(path, radius)
Get path with points inside the channel removed.
getSquareIsOccupied(pixelTable, x, y)
Determine if a square around the x and y pixel coordinates is occupied.
getSquareLoop(beginComplex, endComplex)
Get a square loop from the beginning to the end and back.
getSquareValues(pixelTable, x, y)
Get a list of the values in a square around the x and y pixel coordinates.
getSquareValuesFromPoint(pixelTable, point)
Get a list of the values in a square around the point.
getStepKey(x, y)
Get step key for x and y.
getStepKeyFromPoint(point)
Get step key for the point.
getThreeSignificantFigures(number)
Get number rounded to three significant figures as a string.
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.
getUnitPolar(angle)
Get polar complex from counterclockwise angle from 1, 0.
getXIntersection(firstComplex, secondComplex, y)
Get where the line crosses y.
getXIntersectionsFromIntersections(xIntersectionIndexList)
Get x intersections from the x intersection index list, in other words subtract non negative intersections from negatives.
getXYComplexFromVector3(vector3)
Get an xy complex from a vector3 if it exists, otherwise return None.
getZComponentCrossProduct(vec3First, vec3Second)
Get z component cross product of a pair of Vector3s.
isInFilledRegion(loops, point)
Determine if the left point is in the filled region of the loops.
isInsideOtherLoops(loopIndex, loops)
Determine if a loop in a list is inside another loop in that list.
isLineIntersectingInsideXSegment(segmentFirstX, segmentSecondX, vector3First, vector3Second, y)
Determine if the line is crossing inside the x segment.
isLineIntersectingLoop(loop, pointBegin, pointEnd)
Determine if the line is intersecting loops.
isLineIntersectingLoops(loops, pointBegin, pointEnd)
Determine if the line is intersecting loops.
isLoopIntersectingInsideXSegment(loop, segmentFirstX, segmentSecondX, segmentYMirror, y)
Determine if the loop is intersecting inside the x segment.
isLoopIntersectingLoop(loop, otherLoop)
Determine if the loop is intersecting the other loop.
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.
isPathEntirelyInsideLoop(loop, path)
Determine if a path is entirely inside another loop.
isPathEntirelyInsideLoops(loops, path)
Determine if a path is entirely inside another loop in a list.
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.
isPixelTableIntersecting(bigTable, littleTable, maskTable={})
Add path to the pixel table.
isPointInsideLoop(loop, point)
Determine if a point is inside another loop.
isPointInsideLoops(loops, point)
Determine if a point is inside a loop list.
isSegmentCompletelyInX(segment, xFirst, xSecond)
Determine if the segment overlaps within x.
isWiddershins(polygonComplex)
Determine if the complex polygon goes round in the widdershins direction.
isWithinChannel(channelRadius, pointIndex, loop)
Determine if the the point is within the channel between two adjacent points.
isXSegmentIntersectingPath(path, segmentFirstX, segmentSecondX, segmentYMirror, y)
Determine if a path is crossing inside the x segment.
isXSegmentIntersectingPaths(paths, segmentFirstX, segmentSecondX, segmentYMirror, y)
Determine if a path list is crossing inside the x segment.
joinSegmentTables(fromTable, intoTable)
Join both segment tables and put the join into the intoTable.
joinXIntersectionsTables(fromTable, intoTable)
Join both XIntersections tables and put the join into the intoTable.
removeElementFromListTable(element, key, listTable)
Remove an element from the list table.
removeElementFromPixelListFromPoint(element, pixelTable, point)
Remove an element from the pixel list.
removePixelTableFromPixelTable(pixelTableToBeRemoved, pixelTableToBeRemovedFrom)
Remove pixel from the pixel table.
subtractXIntersectionsTable(subtractFromTable, subtractTable)
Subtract the subtractTable from the subtractFromTable.
toggleHashtable(hashtable, key, value)
Toggle a hashtable between having and not having a key.
transferClosestFillLoop(extrusionHalfWidth, 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'
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

 
Author
        Enrique Perez (perez_enrique@yahoo.com)