import decodes.core as dc from decodes.core import * outie = dc.makeOut(dc.outies.Rhino, "wayout") o = Point(0,0,10) vx = Vec(0,0,10) vy = Vec(0,10,0) cs1 = CS(o,vx,vy) cs2 = CS(Point(),Vec(1,0),Vec(0,1)) for g in [cs1,cs2] : outie.put(g) pa = Point(2,1,10) pb = Point(2,1,11) pc = Point(2,1,12) cs3 = CS(pc+Vec(0,0,1)) for g in [pa,pb,pc,cs3] : outie.put(g) xf = Xform.change_basis(cs1,cs2) csx = cs3*xf pax,pbx,pcx = map(lambda pt:pt*xf,[pa,pb,pc]) for g in [pax,pbx,pcx,csx] : outie.put(g) # for g in parr : outie.put(g) outie.draw()
import decodes.core as dc from decodes.core import * import math, copy outie = dc.makeOut(dc.outies.Rhino, "basistest") outie_red = dc.makeOut(dc.outies.Rhino, "redstuff") outie_red.set_color(1.0,0,0) #print "CS basis" #cs = CS(Point(5,5),Vec(1,-1)) #pts = [Point(t,math.sin(t),0,basis=cs) for t in drange(0,math.pi*2,5)] #outie.put([cs,pts]) #print "here are the points defined relative to their base:" #for p in pts : print p #print "here they are in world coords:" #for p in pts : print p.basis_applied() #print "you can also access point coords as you would expect, using the _x,_y, and _z attributes" #print "%s,%s,%s" %(pts[2]._x,pts[2]._y,pts[2]._z) #print "using the x,y and z attributes returns world coords" #print "%s,%s,%s" %(pts[2].x,pts[2].y,pts[2].z) # #print "if we strip the basis off, points will default to the basis of R3:" #pts = [p.basis_stripped() for p in pts] #outie.put(pts) print "CylCS basis" print "let's plot the same points in two different bases..." cylindrical_cs = CylCS(Point(-4,0))
import decodes.core as dc from decodes.core import * outie = dc.makeOut(dc.outies.Rhino, "linetest") print "constructors" p = Point(1,1) v = Vec(0,0,1) seg1 = Segment(p,v) outie.put(seg1) p0 = Point(-1,1) p1 = Vec(-2,1) seg2 = Segment(p0,p1) outie.put(seg2) ray1 = Ray(Point(0,-1),Vec(0,0,1)) outie.put(ray1) lin1 = Line(Point(0,1),Vec(0,0,1)) outie.put(lin1) outie.draw()
import decodes.core as dc from decodes.core import * outie = dc.makeOut(dc.outies.Rhino, "wayout") o = Point(0, 0, 10) vx = Vec(0, 0, 10) vy = Vec(0, 10, 0) cs1 = CS(o, vx, vy) cs2 = CS(Point(), Vec(1, 0), Vec(0, 1)) for g in [cs1, cs2]: outie.put(g) pa = Point(2, 1, 10) pb = Point(2, 1, 11) pc = Point(2, 1, 12) cs3 = CS(pc + Vec(0, 0, 1)) for g in [pa, pb, pc, cs3]: outie.put(g) xf = Xform.change_basis(cs1, cs2) csx = cs3 * xf pax, pbx, pcx = map(lambda pt: pt * xf, [pa, pb, pc]) for g in [pax, pbx, pcx, csx]: outie.put(g) # for g in parr : outie.put(g) outie.draw()
import decodes.core as dc from decodes.core import * import Rhino import rhinoscriptsyntax as rs outie = dc.makeOut(dc.outies.Rhino, "vectest") print "constructors" v0 = Vec(1,-2) p0 = Point(0,2,2) p1 = Point(1,1,1) v1 = Vec(p0,p1) outie.put([p1,p0,v0,v1]) print "operators" v0 = Vec(0,0,1) v1 = Vec(0,2) v2 = v0+v1 # __add__ v3 = v1-v0 # __sub__ v4 = v0/2 # __div__ v5 = v0*3 # __mul__ v6 = ~v0 # __inv__ outie.put([v0,v1,v2,v3,v4,v5,v6]) print "cross product, dot product, projection angles"
import decodes.core as dc from decodes.core import * outie = dc.makeOut(dc.outies.Rhino, "pointtest") print "constructors" v0 = Vec(1,-2) p0 = Point(0,2,2) p1 = Point(1,1,1) v1 = Vec(p0,p1) p2 = Point(v1) outie.put([p1,p0,v0,v1,p2]) print "operators" # operations between points and vectors are performed in basis space p0 = Point(0,2) v = Vec(0,0,1) p2 = p0+v # __add__ p3 = p0-v # __sub__ p4 = p0/2 # __div__ p5 = p0*3 # __mul__ p6 = ~p0 # __inv__ #outie.put([p0,p2,p3,p4,p5,p6]) print "random points" #TODO: random points
import decodes.core as dc from decodes.core import * import math, copy outie = dc.makeOut(dc.outies.Rhino, "basistest") outie_red = dc.makeOut(dc.outies.Rhino, "redstuff") outie_red.set_color(1.0, 0, 0) #print "CS basis" #cs = CS(Point(5,5),Vec(1,-1)) #pts = [Point(t,math.sin(t),0,basis=cs) for t in drange(0,math.pi*2,5)] #outie.put([cs,pts]) #print "here are the points defined relative to their base:" #for p in pts : print p #print "here they are in world coords:" #for p in pts : print p.basis_applied() #print "you can also access point coords as you would expect, using the _x,_y, and _z attributes" #print "%s,%s,%s" %(pts[2]._x,pts[2]._y,pts[2]._z) #print "using the x,y and z attributes returns world coords" #print "%s,%s,%s" %(pts[2].x,pts[2].y,pts[2].z) # #print "if we strip the basis off, points will default to the basis of R3:" #pts = [p.basis_stripped() for p in pts] #outie.put(pts) print "CylCS basis" print "let's plot the same points in two different bases..." cylindrical_cs = CylCS(Point(-4, 0)) orthogonal_cs = CS(Point(4, 0))
import decodes.core as dc from decodes.core import * outie = dc.makeOut(dc.outies.Rhino, "wayout") import scriptcontext import System import Rhino from decodes.core.outies.rhinoUtil import * import math ''' print "from rhino transform" rh_xform = Rhino.Geometry.Transform.Translation(VecToVec3d(Vec(10,20,30))) xf = Xform.from_rh_transform(rh_xform) print rh_xform print xf ''' ''' print "to rhino transform" xf = Xform(99) rh_xform = Xform.to_rh_transform(xf) print rh_xform print xf ''' ''' print "matrix multiplication" vec = Vec(1,1,1) rotPt = Point(1,1)
import decodes.core as dc from decodes.core import * import Rhino import rhinoscriptsyntax as rs outie = dc.makeOut(dc.outies.Rhino, "vectest") print "constructors" v0 = Vec(1, -2) p0 = Point(0, 2, 2) p1 = Point(1, 1, 1) v1 = Vec(p0, p1) outie.put([p1, p0, v0, v1]) print "operators" v0 = Vec(0, 0, 1) v1 = Vec(0, 2) v2 = v0 + v1 # __add__ v3 = v1 - v0 # __sub__ v4 = v0 / 2 # __div__ v5 = v0 * 3 # __mul__ v6 = ~v0 # __inv__ outie.put([v0, v1, v2, v3, v4, v5, v6]) print "cross product, dot product, projection angles" v0 = Vec(2, 0) v1 = Vec(2, 2) vUp = v0.cross(v1) vDwn = v1.cross(v0)
import decodes.core as dc from decodes.core import * outie = dc.makeOut(dc.outies.Rhino, "wayout") import scriptcontext import System import Rhino from decodes.core.outies.rhinoUtil import * import math ''' print "from rhino transform" rh_xform = Rhino.Geometry.Transform.Translation(VecToVec3d(Vec(10,20,30))) xf = Xform.from_rh_transform(rh_xform) print rh_xform print xf ''' ''' print "to rhino transform" xf = Xform(99) rh_xform = Xform.to_rh_transform(xf) print rh_xform print xf ''' ''' print "matrix multiplication" vec = Vec(1,1,1) rotPt = Point(1,1) ang = math.pi/2 rh_xformA = Rhino.Geometry.Transform.Rotation(ang,VecToVec3d(vec),VecToPoint3d(rotPt)) xfA = Xform.rotation(center=rotPt, angle=ang, axis=vec) print rh_xformA