Hello everyone,
I am going through the following piece if code :
Inputs:
initP: Starting point
dir: vector in the UV directions
L: desired length between the points
bSrf: the surface the points are mapped to
UVi: Optional, may be used to restrict number of points along the vectors
Output:
UV: Number of points in the UV direction
pUV: List of points in the UV direction """
__author__ = "Tim Chen"
__version__ = "2018.05.10"
Thankyou.
I am going through the following piece if code :
Inputs:
initP: Starting point
dir: vector in the UV directions
L: desired length between the points
bSrf: the surface the points are mapped to
UVi: Optional, may be used to restrict number of points along the vectors
Output:
UV: Number of points in the UV direction
pUV: List of points in the UV direction """
__author__ = "Tim Chen"
__version__ = "2018.05.10"
import ghpythonlib.treehelpers as th
import rhinoscriptsyntax as rs
import math
def linearMap(initP, dir1, dir2, L):
pList=[]
pList.append(initP)
prevP=initP
first=True
while True:
cirPlane=rs.PlaneFromNormal(prevP,dir2) # Create a plane orthogonal to dir2
cirCrv=rs.AddCircle(cirPlane,L) # Create a circle on that plane
intP=rs.CurveBrepIntersect(cirCrv,bSrf)[1] # Comput the intersection between the circle and the surface
if first==True: # The first circle may have two equidistant intersection points
first=False
testP=rs.CopyObject(initP,dir1*2) # Create a test point in the positive dir1 direction
if len(intP)>1: # if there are two intersections, that means there's a point on either side of the initP
if rs.Distance(testP,intP[0])<rs.Distance(testP,intP[1]): # The one that's closer to the test point is retained
tempP=intP[0]
else:
tempP=intP[1]
elif len(intP)==1: # if there's one point then pick that point, this happens when the initP is close to the edge of the surface
if rs.Distance(testP,intP[0])<rs.Distance(initP,intP[0]):
tempP=intP[0]
else:
break
else: # else there is no intersection
break
else: # subsequent circles
if len(intP)>1: # If there are two intersecting points, so it hasn't fallen off the surface
if rs.Distance(pList[-2],intP[0])>rs.Distance(pList[-2],intP[1]): # retain the point that's not already on the list
tempP=intP[0]
else:
tempP=intP[1]
else:
break
prevP=tempP
pList.append(tempP)
return pListHere on line 18 what is being done? why [1] being added a the end, I am confused,plz help.Thankyou.
