| 
  | 
hi,
as a part of a process I calculate two random-ish 3d points which are the base
and cap centres of a cylinder.  I now want to transform the cylinder such that
the base is at origin and the Y axis is the centre axis.  after adding some
points relative to the centre axis, I need to transform the cylinder back to its
original position.
as the cylinder is "oriented", I cannot fathom how/where to get "my angles" wrt
the POV-Ray "world" axes.  can someone please take me through a worked example,
or point out a good www resource?  tia.
regards, jr.
 
 Post a reply to this message 
 | 
  | 
 | 
  | 
Le 19-02-23 à 08:38, jr a écrit :
> hi,
> 
> as a part of a process I calculate two random-ish 3d points which are the base
> and cap centres of a cylinder.  I now want to transform the cylinder such that
> the base is at origin and the Y axis is the centre axis.  after adding some
> points relative to the centre axis, I need to transform the cylinder back to its
> original position.
> 
> as the cylinder is "oriented", I cannot fathom how/where to get "my angles" wrt
> the POV-Ray "world" axes.  can someone please take me through a worked example,
> or point out a good www resource?  tia.
> 
> 
> regards, jr.
> 
> 
If you want an end of the cylinder to get moved to the origin, a simple 
translate by the inverse of it's coordinate will do the trick :
You must set Range1, Range2, Offset1 and Offset2 to your needs.
#include "transforms.inc"
#declare R=seed(34);
...
#declare End1= <rand(R), rand(R), rand(R)>*Range1+Offset1
#declare End2= <rand(R), rand(R), rand(R)>*Range2+Offset2
#declare MyCylinder = cylinder{End1, End2, Radius}
//Move End1 to the origin :
#declare CylinderAtOrigin = object{MyCylinder translate -End1}
*//Reorient it to the Y axis :
#declare WorkCylinder = object{CylinderAtOrigin 
transform{Reorient_Trans(End2, y)}}
Do whatever else you want here...
//Restore the original orientation :
#declare CylinderAtOrigin = object{WorkCylinder 
transform{Reorient_Trans(y, End2)}}
//Bring back to the original location :
#declare MyCylinder = object{CylinderAtOrigin translate End1}
It can be shortened by combining the translations and rotations :
#declare WorkCylinder = object{MyCylinder translate -End1 
transform{Reorient_Trans(End2, y)}}
Do whatever else you want here...
// Restore original orientation and location :
#declare MyCylinder = object{WorkCylinder transform{Reorient_Trans(y, 
End2)} translate End1}
Alain
 Post a reply to this message 
 | 
  |