Ejemplo n.º 1
0
def IsPointInside(meshId, pt, tolerance = 1e-6):
	faceVerts = rs.MeshFaces(meshId, face_type=False)
	totalAngle = 0
	i = 0
	while i < len(faceVerts):
		ptA = faceVerts[i]
		ptB = faceVerts[i + 1]
		ptC = faceVerts[i + 2]
		
		a = rs.VectorSubtract(ptA, pt)
		b = rs.VectorSubtract(ptB, pt)
		c = rs.VectorSubtract(ptC, pt)
		
		angle = GetSolidAngle(a,b,c)
		normal = Normal(ptA, ptB, ptC)
		center = Centroid(ptA, ptB, ptC)
		
		faceVec = rs.VectorSubtract(pt, center)
		dot = rs.VectorDotProduct(normal, faceVec)
		
		factor = 1 if dot > 0 else -1
		totalAngle += angle * factor
		
		i += 3
	
	absTotal = abs(totalAngle)
	
	inside = abs(absTotal - (4*math.pi)) < tolerance
	print("The total solid angle is %.02fPI"%(absTotal/math.pi))
	return inside
Ejemplo n.º 2
0
def Main():

    jointno = 4

    list = []

    dir0 = rs.GetPoint("from")
    dir1 = rs.GetPoint("hub")
    dir2 = rs.GetPoints(False, False, "outline_left_to_right")

    #THIS VECTOR WILL ALLOW US TO TAKE INTO ACCOUNT POSSIBLE LAYOUT OF DRAWN JOINTS ON THE PAGE
    fix = rs.VectorSubtract([0, 0, 0], dir1)

    dir0 = rs.VectorAdd(dir0, fix)
    dir1 = rs.VectorAdd(dir1, fix)
    indir = rs.VectorSubtract(dir1, dir0)

    for j in range(len(dir2)):
        pt = rs.VectorAdd(dir2[j], fix)
        dir2[j] = pt

    list.append([dir1, indir, dir2])

    for i in (range(jointno)[1:]):

        dir0 = rs.GetPoint("from")
        dir1 = rs.GetPoint("hub")
        dir2 = rs.GetPoint("to")

        #THIS VECTOR WILL ALLOW US TO TAKR INTO ACCOUNT POSSIBLE LAYOUT OF DRAWN JOINTS ON THE PAGE
        fix = rs.VectorSubtract([0, 0, 0], dir1)

        #What is this line doing???
        dir0 = rs.VectorAdd(dir0, fix)
        dir1 = rs.VectorAdd(dir1, fix)
        dir2 = rs.VectorAdd(dir2, fix)

        #Setting up direction vectors!
        indir = rs.VectorSubtract(dir1, dir0)
        outdir = rs.VectorSubtract(dir2, dir1)

        lside = rs.GetPoints(False, False, "left")
        rside = rs.GetPoints(False, False, "right")

        for j in range(len(lside)):
            pt = rs.VectorAdd(lside[j], fix)
            lside[j] = pt

        for j in range(len(rside)):
            pt = rs.VectorAdd(rside[j], fix)
            rside[j] = pt

        list.append([dir1, indir, lside, rside, outdir])

    WritePolies(addresss, list)
Ejemplo n.º 3
0
def MirrorX(lineIn, pIn):
    pLine0 = lineIn[0]
    pLine1 = lineIn[1]
    normal = rs.VectorUnitize(
        rs.VectorCrossProduct([0, 0, 1], rs.VectorSubtract(pLine1, pLine0)))
    matrix = rs.XformMirror(pLine1, normal)
    return rs.PointTransform(pIn, matrix)
Ejemplo n.º 4
0
def blendcorners():
    polyline_id = rs.GetObject("Polyline to blend", 4, True, True)
    if not polyline_id: return

    vertices = rs.PolylineVertices(polyline_id)
    if not vertices: return

    radius = rs.GetReal("Blend radius", 1.0, 0.0)
    if radius is None: return

    between = lambda a, b: (a + b) / 2.0
    newverts = []
    for i in range(len(vertices) - 1):
        a = vertices[i]
        b = vertices[i + 1]
        segmentlength = rs.Distance(a, b)
        vec_segment = rs.PointSubtract(b, a)
        vec_segment = rs.VectorUnitize(vec_segment)

        if radius < (0.5 * segmentlength):
            vec_segment = rs.VectorScale(vec_segment, radius)
        else:
            vec_segment = rs.VectorScale(vec_segment, 0.5 * segment_length)

        w1 = rs.VectorAdd(a, vec_segment)
        w2 = rs.VectorSubtract(b, vec_segment)
        newverts.append(a)
        newverts.append(between(a, w1))
        newverts.append(w1)
        newverts.append(between(w1, w2))
        newverts.append(w2)
        newverts.append(between(w2, b))
    newverts.append(vertices[len(vertices) - 1])
    rs.AddCurve(newverts, 5)
    rs.DeleteObject(polyline_id)
Ejemplo n.º 5
0
def TransformProfile(object, pt1, pt2):
    normal = rs.VectorSubtract(pt1, pt2)
    normal = rs.VectorUnitize(normal)

    plane = rs.PlaneFromNormal(pt1, normal)

    transformation = rs.XformRotation1((rs.WorldXYPlane), normal)
    profiletras = rs.TransformObject(object, transformation, True)
Ejemplo n.º 6
0
def copyToOrigin(objs):

    #get left bottom
    selection_base = rs.GetPoint("Pick export base point")
    #box = rs.BoundingBox(objs)
    if selection_base:
        #selection_base = [box[0].X, box[0].Y, box[0].Z]
        vector = rs.VectorSubtract(selection_base, [0, 0, 0])

        return rs.CopyObjects(objs, rs.VectorReverse(vector))
Ejemplo n.º 7
0
    def drawEdge(self,nodes):
        p1 = self.posVec
        p2 = nodes[self.parentID].posVec
        self.geom.append(rs.AddLine(p1,p2))

        pNormal = rs.VectorSubtract(p2,p1)
        height = rs.VectorLength(pNormal)
        plane = rs.PlaneFromNormal(p1,pNormal)
        radius = self.radius
        self.geom.append(rs.AddCylinder(plane,height,radius))
Ejemplo n.º 8
0
 def attractor(self, mag):
      
     attrPt = rs.VectorCreate((-800,-700,0) , (0,0,0))
     steer = rs.VectorCreate( (0,0,0) , (0,0,0) )
     diff = rs.VectorSubtract( attrPt, self.p )
     diff = rs.VectorUnitize(diff)
      
     steer = rs.VectorAdd(steer , diff)
     steer = rs.VectorScale(steer, mag)
       
     self.a = rs.VectorAdd(self.a, steer)
Ejemplo n.º 9
0
 def attract(self, mover):
     forceDir = rs.VectorSubtract(self.location, mover.location)
     forceMag = rs.Distance(self.location, mover.location)
     forceMag = limit(forceMag, 2.0, 27.0)
     forceDir = rs.VectorUnitize(forceDir)
     # print forceDir
     strength = (self.g * self.mass) / (forceMag * forceMag)
     # strength = limit(strength,1,15)
     # print strength
     finalForce = rs.VectorScale(forceDir, strength)
     return finalForce
Ejemplo n.º 10
0
def moveToOrigin(objs, origin):

    #box = rs.BoundingBox(objs)
    if origin:
        #selection_base = [box[0].X, box[0].Y, box[0].Z]
        vector = rs.VectorSubtract(origin, [0, 0, 0])

        objs = rs.MoveObjects(objs, rs.VectorReverse(vector))
        return True
    else:
        return False
Ejemplo n.º 11
0
 def _get_centering_vec(self, curve_id, extra_space):
     '''
     gets the vector that is aligned with curve, and whos length
     is half of extra_space
     '''
     dist = extra_space / 2.0
     start = rs.CurveStartPoint(curve_id)
     end = rs.CurveEndPoint(curve_id)
     vec = rs.VectorSubtract(end, start)
     vec_unit = rs.VectorUnitize(vec)
     vec_scaled = rs.VectorScale(vec_unit, dist)
     return vec_scaled
Ejemplo n.º 12
0
def throwNode(nodes,speed,stickRange,passParams,resizeThreshold):
    boundRadius = passParams[0]
    bGeom = passParams[1]
    #sFactor = passParams[2]
    #print passParams[2]
    #assumes time steps of 1
    startPos = getBoundaryPos(boundRadius);
    endPos = getBoundaryPos(boundRadius);
    
    direction = rs.VectorSubtract(endPos,startPos)
    direction = rs.VectorUnitize(direction)
    vel = rs.VectorScale(direction,speed);

    currentPos = rs.VectorAdd(startPos,vel)

    previewGeom = []

    isTravelling = True
    while(isTravelling):
        scriptcontext.escape_test() #hit escape to quit NOT WORKING
        time.sleep(0.01*10**-7)
        for o in previewGeom: rs.DeleteObjects(o)
        dist = rs.VectorLength(currentPos) #distance to origin
        #check if particle went out of bounds
        if(dist>boundRadius):
            isTravelling = False
       
        else:
            previewGeom.append(drawPos(currentPos,stickRange))
            for i in range(len(nodes)):
                n = nodes[i]
                if(inStickRange(currentPos,n,stickRange)):
                    #GOT STUCK! add a new node at that position
                    newNode = node(currentPos,i,.08) #parent is idx of node stuck too
                    newNode.increaseRadius(.01, nodes)
                    nodes.append(newNode)
                    #rNodes.append(rs.AddPoint(currentPos))
                    if(math.fabs(boundRadius-dist) <= resizeThreshold):
                        #print "boundRadius should resize"
                        rs.DeleteObjects(bGeom)
                        boundRadius += resizeThreshold/2 #arbitrary
                        bGeom = rs.AddCircle([0,0,0],boundRadius)
                        passParams[0] = boundRadius
                        passParams[1] = bGeom

                    isTravelling = False
                    for o in previewGeom: rs.DeleteObjects(o)
                    break
            
            currentPos = rs.VectorAdd(currentPos,vel)
        Rhino.RhinoApp.Wait()
        
    return passParams
Ejemplo n.º 13
0
def main():

  diameter = rs.GetReal("enter cutter diameter", number=0.25)
  diameter = diameter*1.1
  # first, select objects in three orthogonal planes
  obj = rs.GetObject("select object", filter=4) # curve
  curve_points = rs.CurvePoints(obj)[:-1]

  circles = []
  while True:
    point = rs.GetPoint("select point")
    if point is None:
      break
    try:
      idx = curve_points.index(point)
      print "clicked index", idx
    except ValueError:
      print "invalid point"
      continue

    points = [
      curve_points[(idx+1)%len(curve_points)],
      curve_points[idx                      ],
      curve_points[(idx-1)%len(curve_points)],
    ]
    print points

    angle = rs.Angle2(
        (points[1], points[0]),
        (points[1], points[2]),
    )
    angle = angle[0]

    point = rs.VectorAdd(
      points[1], 
      rs.VectorRotate(0.5*diameter*rs.VectorUnitize(rs.VectorSubtract(points[2], points[1])), angle/2, (0,0,1))
    )

    #p0 = (point.X, point.Y, point.Z + 1000)
    #p1 = (point.X, point.Y, point.Z - 1000)

    circle = rs.AddCircle(point, diameter/2.0)
    circles.append(circle)

    #extrusion = rs.ExtrudeCurveStraight(circle, p0, p1)

  for circle in circles:
    before_obj = obj
    obj = rs.CurveBooleanDifference(obj, circle)
    rs.DeleteObject(before_obj)

  rs.DeleteObjects(circles)
Ejemplo n.º 14
0
def splitSrfVerticallyByPts(srf,pts):
    normals=[]
    up=(0,0,1000000000)
    half=(0,0,500000000)
    cutters=[]
    for p in pts:
        uv=rs.SurfaceClosestPoint(srf,p)
        normal=rs.SurfaceNormal(srf,uv)
        normal=rs.VectorScale(normal,1000)
        normals.append(normal)
        botStart=rs.VectorAdd(rs.VectorSubtract(p,half),normal)
        botEnd=rs.VectorSubtract(rs.VectorSubtract(p,half),normal)

        l=rs.AddLine(botStart,botEnd)
        path=rs.AddLine(botStart,rs.VectorAdd(botStart,up))
        cutter=rs.ExtrudeCurve(l,path)
        rs.DeleteObjects([l,path])

        #print(rs.IsBrep(cutter))
        #print(cutter)
        cutters.append(cutter)
    # rs.SelectObjects(cutters)
    srfs=splitSrfBySrfs(srf,cutters)
    return srfs
Ejemplo n.º 15
0
def ResetBlockScale():
    try:
        blocks = rs.GetObjects("Select blocks to reset",
                               rs.filter.instance,
                               preselect=True)
        if blocks is None: return

        points = [
            rg.Point3d(0, 0, 0),
            rg.Point3d(1, 0, 0),
            rg.Point3d(0, 1, 0),
            rg.Point3d(0, 0, 1)
        ]

        for block in blocks:
            xform = rs.BlockInstanceXform(block)
            namne = rs.BlockInstanceName(block)

            pts = rg.Polyline(points)

            pts.Transform(xform)

            finalOrigin = pts[1]
            finalXaxis = rs.VectorSubtract(pts[1], pts[0])
            finalYaxis = rs.VectorSubtract(pts[2], pts[0])
            finalPlane = rg.Plane(finalOrigin, finalXaxis, finalYaxis)

            xFac = 1 / rs.Distance(pts[1], pts[0])
            yFac = 1 / rs.Distance(pts[2], pts[0])
            zFac = 1 / rs.Distance(pts[3], pts[0])

            newXForm = rg.Transform.Scale(finalPlane, xFac, yFac, zFac)
            rs.TransformObject(block, newXForm)
        return True
    except:
        return False
Ejemplo n.º 16
0
def get_perpendicular_vector_to_points(pntI, pntJ, left=True):
    '''
    returns a unitized vector perpendicular to the vector formed 
    from pntI to pntJ
    ^
    |
    I-------> J
    '''
    normal = [0, 0, 1]
    angle = 90.0
    if not left:
        angle = -1.0 * angle
    vec = rs.VectorSubtract(pntJ, pntI)
    vec = rs.VectorRotate(vec, angle, normal)
    return rs.VectorUnitize(vec)
def guessHorizontalShift():
    """
    This script will correct the horizontal distortion and set it in the V-Ray Camera.
    It levels the camera for this correction to work well and resets
    lens shift (vertical shift) to 0
    Works with V-Ray 5.1
        
    version 0.4
        
    www.studiogijs.nl
    """
    viewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
    if viewport.IsParallelProjection:
        print "Stupid, you should select a perspective view"
        return
    view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
    #set camera location to target height
    pt = view.CameraLocation
    pt[2] = view.CameraTarget.Z
    dir = rs.VectorSubtract(view.CameraTarget, pt)
    view.SetCameraLocation(pt, False)
    view.SetCameraDirection(dir, False)

    #calculate camera direction angle relative to WorldXY plane
    cam = view.CameraZ
    vec = Rhino.Geometry.Vector3d(1, 0, 0)
    plane = Rhino.Geometry.Plane.WorldXY
    angle = Rhino.Geometry.Vector3d.VectorAngle(cam, vec, plane)

    #calculate the correction factor
    for i in range(3):
        if angle > math.pi / 2:
            angle -= math.pi / 2
        else:
            break

    if 0 <= angle < math.pi / 4:
        factor = math.tan(angle)

    if math.pi / 4 <= angle < math.pi / 2:
        factor = -math.tan(math.pi / 2 - angle)

    rv = rs.GetPlugInObject("V-Ray for Rhino").Scene().Plugin(
        "/CameraPhysical")
    rv.Param("horizontal_shift").Value = factor
    print "Horizontal shift factor set to %r." % factor
    rv.Param("lens_shift").Value = 0
    rs.Redraw()
Ejemplo n.º 18
0
def surfaceIrradiance_fixed(towerIn, sunIn, intensityIn):
    sunUnit = rs.VectorUnitize(sunIn)
    for floor in range(len(towerIn)):
        numPoints = len(towerIn[floor])
        for i in range(numPoints):
            p1 = towerIn[floor][i]
            p2 = towerIn[floor][(i + 1) % numPoints]
            v1 = rs.VectorSubtract(p2, p1)
            v2 = [0, 0, 1]
            n = rs.VectorCrossProduct(v1, v2)
            if rs.VectorLength(n) > rs.UnitAbsoluteTolerance(10**(-3), True):
                cosTheta = rs.VectorDotProduct(rs.VectorUnitize(n), sunUnit)
                if cosTheta > 0:
                    factor = intensityIn * cosTheta / 200  #200 is just to shorten the vector to something manageable
                    v = rs.VectorScale(n, factor)
                    AddVector(v, p1)
Ejemplo n.º 19
0
def grow(num):
	#this method grows the global ptArray list
	#this method grows teh pointClooud represented by this list
	if num == 0:
		return 0
	randPt = randomPt(-25,25,-25,25,0,50)
	
	joinNode = nodeList[rs.PointArrayClosestPoint(ptArray, randPt)]
	joinPt = joinNode.pos
	joinVec = rs.VectorSubtract(randPt, joinPt)
	
	growthVec = rs.VectorUnitize(joinVec)
	newPt = rs.VectorAdd(joinPt, growthVec)
	
	newNode = node(newPt, joinNode)
	g = grow(num-1)
Ejemplo n.º 20
0
def moveToOrigin(objs):
    #get left bottom

    rs.EnableRedraw(True)
    selection_base = rs.GetPoint("Pick export base point")
    rs.EnableRedraw(False)

    #box = rs.BoundingBox(objs)
    if selection_base:
        #selection_base = [box[0].X, box[0].Y, box[0].Z]
        vector = rs.VectorSubtract(selection_base, [0, 0, 0])

        objs = rs.MoveObjects(objs, rs.VectorReverse(vector))
        return True
    else:
        return False
def get_addition_columns(a,b):
    sq2 = math.sqrt(2.0)
    if a<ra and b<ra:
        p = rg.Vector2d(a,b)
        columnradius = ra * sq2 / ((n-1) * 2 + sq2)
        p = rot45(p)
        p = rs.VectorSubtract(p,rg.Vector3d(sq2 / 2 * ra,0,0))
        p = rs.VectorAdd(p,rg.Vector3d(columnradius*sq2,columnradius*sq2,0))
        if n%2==1:
            p = rs.VectorAdd(p,rg.Vector3d(0,columnradius,0))
        p.Y = mod1(p.Y, columnradius*2)
        result = p.Length-columnradius
        result = min(result, p.X)
        result = min(result, a)
        return min(result, b)
    else:
        return min(a,b)
Ejemplo n.º 22
0
 def cohesion(self, mag):
       
     sum = rs.VectorCreate( (0,0,0) , (0,0,0) )
     count = 0
       
     for i in pts:
         distance = rs.Distance(i.p, self.p)
         if distance > 0 and distance < 60:
             sum = rs.VectorAdd(sum, i.p)
             count += 1
       
     if count>0:
         sum = rs.VectorScale(sum, 1.0/count)
       
     steer = rs.VectorSubtract(sum, self.p)
     steer = rs.VectorScale(steer, mag)
     self.a = rs.VectorAdd(self.a, steer)
Ejemplo n.º 23
0
 def draw_lpoint_triple(text, tail, head):
     """Receives label text and a list of point triples:
         str
         [<iter>, ...]
     Draws text dots with <text>-a, -b, -c
     """
     line_vector = rs.PointSubtract(head, tail)
     offset_vector = line_vector * offset
     offset_tail = rs.VectorAdd(tail, offset_vector)
     offset_head = rs.VectorSubtract(head, offset_vector)
     axis = [0, 0, 1]
     angle = 90
     rotated_offset_vector = rs.VectorRotate(offset_vector, angle, axis)
     offset_side = rs.VectorAdd(offset_tail, rotated_offset_vector)
     rs.AddTextDot(('%s-a' % text), offset_tail)
     rs.AddTextDot(('%s-b' % text), offset_head)
     rs.AddTextDot(('%s-c' % text), offset_side)
Ejemplo n.º 24
0
    def grow(self):
        x1 = self.node[0][0] - (self.size[1] / 2)
        x2 = self.node[0][0] + (self.size[1] / 2)
        y1 = self.node[0][1] - (self.size[1] / 2)
        y2 = self.node[0][1] + (self.size[1] / 2)
        z1 = self.node[0][2]
        z2 = self.node[0][2] + self.size[0]

        i = 0
        while i < self.twigCount:
            randPt = placePt(x1, x2, y1, y2, z1, z2)
            joinPt = self.node[rs.PointArrayClosestPoint(self.node, randPt)]
            vec = rs.VectorScale(
                rs.VectorUnitize(rs.VectorSubtract(randPt, joinPt)),
                self.segLength)
            newPt = rs.PointAdd(joinPt, vec)
            self.addTwig(joinPt, newPt)
            i += 1
Ejemplo n.º 25
0
    def GetPointDynamicDrawFunc(sender, args):
        point_b = args.CurrentPoint
        point_C = Rhino.Geometry.Point3d((point_a.X + point_b.X) / 2,
                                         (point_a.Y + point_b.Y) / 2,
                                         (point_a.Z + point_b.Z) / 2)
        #Rhino.Geometry.Transform.Translation(
        vec = rs.VectorCreate(point_b, point_a)
        rs.VectorUnitize(vec)
        vec2 = rs.VectorScale(vec, 500)
        vec3 = rs.coerce3dpoint(rs.VectorAdd(point_b, vec2))
        rs.VectorReverse(vec2)
        vec4 = rs.coerce3dpoint(rs.VectorSubtract(point_b, vec2))

        args.Display.DrawLine(point_a, vec3, line_color_1, 1)
        args.Display.DrawLine(point_a, vec4, line_color_1, 1)
        args.Display.DrawPoint(point_a, Rhino.Display.PointStyle.ControlPoint,
                               3, line_color_1)
        args.Display.DrawPoint(point_b, Rhino.Display.PointStyle.ControlPoint,
                               3, line_color_2)
Ejemplo n.º 26
0
 def separate(self, mag):
       
     steer = rs.VectorCreate( (0,0,0) , (0,0,0) )
     count = 0
       
     for i in pts:
         distance = rs.Distance(i.p, self.p)
         if distance > 0 and distance < 30:
             diff = rs.VectorSubtract(self.p, i.p)
             diff = rs.VectorUnitize(diff)
             diff = rs.VectorScale(diff, 1.0/distance)
               
             steer = rs.VectorAdd(steer , diff)
             count += 1
       
     if count>0:
         steer = rs.VectorScale(steer, 1.0/count)
       
     steer = rs.VectorScale(steer, mag)
     self.a = rs.VectorAdd(self.a, steer)
    def SeparationVector(self):

        sum = [0, 0, 0]

        count = 0

        for i in range(len(agentlist)):

            if self.pos is not agentlist[i].pos:
                dis = rs.Distance(self.pos, agentlist[i].pos)
                self.setFlag(dis)

                if self.doSeparation:
                    sum = rs.VectorSubtract(sum, agentlist[i].pos)
                    count += 1

        #avepos = rs.VectorScale (sum, 1/count)
        avepos = rs.VectorScale(sum, count)
        resultingVec = rs.VectorCreate(avepos, self.pos)
        resultingVec = vectorlimit(resultingVec, self.mf)

        return resultingVec
    def avoid(self):
        if obstacle:
            avoid = [0, 0, 0]
            count = 0
            sumradar = 0
            averadar = 0
            for i in range(len(obstacle)):
                judge = rs.MeshClosestPoint(obstacle[i], self.pos)
                radar = rs.Distance(self.pos, judge[0])
                vecradar = rs.VectorCreate(self.pos, judge[0])
                #            print radar
                if radar < 0.5:
                    self.pos = rs.VectorSubtract(self.posP, self.pos)
                    vecradar = rs.VectorScale(vecradar, 2)

                if radar < 3 and radar > 0.5:
                    avoid = rs.VectorAdd(avoid, judge[0])
                    sumradar += radar
                    count += 1
                    vecradar = rs.VectorScale(vecradar, 0.5)
                    obstacle[i] = rs.MoveObject(obstacle[i], vecradar)
            if count != 0:
                aveavoid = rs.VectorScale(avoid, 1 / count)
                averadar = sumradar / count
            else:
                aveavoid = self.pos
                averadar = averadar + 24
            vec1 = rs.VectorCreate(self.pos, aveavoid)
            vec1 = rs.VectorScale(vec1, ((averadar + 24) / averadar)**2)
            if rs.VectorLength(vec1) > 1:
                vec1 = vectorlimit(vec1, 1)

    #           n = rnd.randint(0,10)
    #        vec1 = rs.VectorRotate (vec1,-60,[0,0,1])

        else:
            vec1 = [0, 0, 0]

        return vec1
Ejemplo n.º 29
0
    def __init__(self, GUID_TERRAIN, CRV, SPEED=1):
        # CLASS PROPERTIES
        pt_from = rs.CurveStartPoint(CRV)
        pt_to = rs.CurveEndPoint(CRV)

        self.pos = pt_from
        self.vel = rs.VectorSubtract(pt_to, pt_from)
        self.vel = rs.VectorUnitize(self.vel)
        self.vel = rs.VectorScale(self.vel, SPEED)
        self.terrain = GUID_TERRAIN
        self.proj_points = []

        self.depth_scans = []  # a list store scan data

        self.history = []  # remember everywhere i have been
        self.history.append(self.pos)
        self.render()  #drawing the 0-text dot
        self.z_distances = []
        self.x_pos = []

        self.z_difference = []
        self.x_difference = []
Ejemplo n.º 30
0
def addcurvaturegraphsection(idCrv, t0, t1, samples, scale):
    if (t1 - t0) <= 0.0: return
    N = -1
    tstep = (t1 - t0) / samples
    t = t0
    points = []
    objects = []
    while t <= (t1 + (0.5 * tstep)):
        if t >= t1: t = t1 - 1e-10
        N += 1
        cData = rs.CurveCurvature(idCrv, t)
        if not cData:
            points.append(rs.EvaluateCurve(idCrv, t))
        else:
            c = rs.VectorScale(cData[4], scale)
            a = cData[0]
            b = rs.VectorSubtract(a, c)
            objects.append(rs.AddLine(a, b))
            points.append(b)
        t += tstep

    objects.append(rs.AddInterpCurve(points))
    return objects