# Can I apply a transformation to a point (list)?

5 messages
Open this post in threaded view
|

## Can I apply a transformation to a point (list)?

 Sometimes it seems like it would be useful to be able to take a given transformation to just a point, and then use that point as a reference later.  For example, let's say I have a transformation: translate([1,2,3]) rotate([4,5,6]) { objects...} it would be nice to be able to do something like: newpt = translate([1,2,3]) rotate([4,5,6]) [x,y,z] and then use newpt for other purposes.  Is something like this possible? Thanks, Nick -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Can I apply a transformation to a point (list)?

Open this post in threaded view
|

## Re: Can I apply a transformation to a point (list)?

Open this post in threaded view
|

## Re: Can I apply a transformation to a point (list)?

Open this post in threaded view
|

## Re: Can I apply a transformation to a point (list)?

 In reply to this post by nicnacs Some very simple functions I made for the purpose. You need to use the two first, but they rely on some of the others, so you need to include them as well. //Translate coordinate function xtrancoord(dx,co)=[co[0]+dx,co[1],co[2]]; //Rotate coordinate function rotcoord(rot,co)=zrotcoord(rot[2],yrotcoord(rot[1],xrotcoord(rot[0],co))); //Translate along one axis only function ytrancoord(dy,co)=[co[0],co[1]+dy,co[2]]; function ztrancoord(dz,co)=[co[0],co[1],co[2]+dz]; function trancoord(d,co)=[co[0]+d[0],co[1]+d[1],co[2]+d[2]]; //Rotate around one axis only function xrotcoord(rx,co)=[co[0],                                                         rotcoord_yz(co[1],co[2],rx)[1],                                                         rotcoord_yz(co[1],co[2],rx)[2]]; function yrotcoord(ry,co)=[rotcoord_xz(co[0],co[2],-ry)[0],                                                         co[1],                                                         rotcoord_xz(co[0],co[2],-ry)[2]]; function zrotcoord(rz,co)=[rotcoord_xy(co[0],co[1],rz)[0],                                                         rotcoord_xy(co[0],co[1],rz)[1],                                                         co[2]]; //Angle between origin and 2D point function angle2d(x2,z2)=-(-90+((0