From: Bruce S. <Bru...@nc...> - 2009-11-25 21:11:44
|
Here is an example: from visual import * f = frame(pos=(2,1,0)) b = box(frame=f, pos=(-3,1,1), size=(.2,.2,.2)) print b.pos print f.frame_to_world(b.pos) print f.world_to_frame(vector(2,1,0)) This yields <-3, 1, 1> <-1, 2, 1> <0, 0, 0> Bruce Sherwood ale ale wrote: > Hi > > I need help to determine the position of an object that is part of a > frame and I don't really understand how to use > * > world_pos = f.frame_to_world (frame_pos) * > > found in online documentation and I'm looking for some examples > > I use a class to define the frame that is composed by a main frame that > contains two frames composed by many objects. > The object ( a servo) is composed by two parts (servo_box and > servo_frame), I can turn the servo_frame arround its axis , but I need > to connect two servo to create a joint like hip, knee .... > Could you show me some examples or documentation that I can study to > better understand how to calculate the points I need? > > > AleAle99 > > > > code like this: > > class ServoWithFrame(): > > def __init__ (self,offset=(0,0,0)): > > self.servo =frame(pos=offset) > > self.servo_box =frame(frame=self.servo) > self.servo_asse =frame(frame=self.servo) > > self.main_box =box(frame=self.servo_box, > pos=(offset),axis=(self.servo_box.lenght,0,0), height = > self.servo_box.height, width > =self.servo_box.width,color=(0.4,0.4,0.4),material=materials.plastic) > self.secondary_box= box(frame=self.servo_box, > pos=((self.main_box.x -(self.servo_box.lenght > -self.servo_box.lenghtb)/2. ),(self.main_box.y+ > self.servo_box.heightb/2.+self.servo_box.height/2.),self.main_box.z > ),axis=(self.servo_box.lenghtb,0,0), height = self.servo_box.heightb, > width =self.servo_box.width,color=(0.4,0.4,0.4),material=materials.plastic) > self.motor_cyl= cylinder (frame=self.servo_box, > pos=((self.main_box.x + self.servo_box.lenghtb/2. - self.servo_box.motor > ),(self.main_box.y -self.servo_box.height -self.servo_box.heightb/2.+1.5 > ),self.main_box.z ), axis=(0,self.servo_box.motor,0), radius > =self.servo_box.width/2.,color=(0.4,0.4,0.4),material=materials.plastic) > self.motor_main= cylinder (frame=self.servo_asse, > pos=((self.main_box.x - self.servo_box.lenght/2. + > self.servo_box.width/2. ),(self.main_box.y -self.servo_box.height/2 - > self.servo_box.attacw),self.main_box.z ), > axis=(0,self.servo_box.attacl,0), radius =self.servo_box.attacw/2., > color=(0.9,0.9,0.95),material=materials.plastic) > self.motor_cylb= cylinder (frame=self.servo_box, > pos=(self.motor_main.x ,self.motor_main.y+ self.servo_box.height+ > self.servo_box.heightb+4.5,self.motor_main.z ), axis=(0,2,0), radius > =self.servo_box.motor/2.,color=(0.4,0.4,0.4),material=materials.plastic) > > self.servo_frame =frame(frame=self.servo) > self.left_circle = cylinder (frame=self.servo_frame, pos = > self.motor_cylb.pos,radius =self.servo_frame.width/2., > lenght=self.servo_frame.thick,material=materials.rough) > self.left_box =box(frame=self.servo_frame, > pos=(self.left_circle.x+0.5,self.left_circle.y > -(self.servo_frame.width/2. -1) , self.left_circle.z), height = > self.servo_frame.height-self.servo_frame.width/2., width > =self.servo_frame.width, > lenght=self.servo_frame.thick,material=materials.rough) > self.right_circle = cylinder (frame=self.servo_frame, > pos=(self.left_circle.x + self.servo_frame.lenght - > self.servo_frame.thick,self.left_circle.y,self.left_circle.z), radius > =self.servo_frame.width/2., > lenght=self.servo_frame.thick,material=materials.rough) > self.right_box =box(frame=self.servo_frame, > pos=(self.right_circle.x+0.5,self.right_circle.y-(self.servo_frame.width/2. > -1) , self.right_circle.z), height = > self.servo_frame.height-self.servo_frame.width/2., width > =self.servo_frame.width, > lenght=self.servo_frame.thick,material=materials.rough) > > self.low_box = box(frame=self.servo_frame, > pos=(self.left_circle.x+self.servo_frame.lenght/2.,self.left_circle.y-self.servo_frame.width/2. > - (self.servo_frame.height-self.servo_frame.width) - > self.servo_frame.thick > ,self.left_circle.z),axis=(self.servo_frame.lenght,0,0), height = 1, > width =self.servo_frame.width,material=materials.rough) > self.side_dx = box(frame=self.servo_frame, pos=(self.low_box.x > -self.servo_frame.thick/2. > ,self.low_box.y+1,self.low_box.z+self.servo_frame.width/2),axis=(self.servo_frame.lenght-4*self.servo_frame.thick,0,0), > height = 3, width =self.servo_frame.thick,material=materials.rough) > self.side_sx = box(frame=self.servo_frame, pos=(self.low_box.x > -self.servo_frame.thick/2. > ,self.low_box.y+1,self.low_box.z-self.servo_frame.width/2),axis=(self.servo_frame.lenght-4*self.servo_frame.thick,0,0), > height = 3, width =self.servo_frame.thick,material=materials.rough) > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > > ------------------------------------------------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |