POV-Ray : Newsgroups : povray.general : alignment! : Re: alignment! Server Time
10 Aug 2024 07:19:41 EDT (-0400)
  Re: alignment!  
From: Josh English
Date: 14 Feb 2000 19:36:00
Message: <38A89F86.AB47943D@spiritone.com>
i use the following when moving an object aligned to the x axis into space.
ns control the objects local sky value, which should be <0,1,0> but if you rotate
this point around the x axis [vrotate(<0,1,0>,<45,0,0>)] you can change the
rotation of the object at the same time.

#macro Orient_X(v1,v2,ns)
  #local nx = vnormalize(v2 - v1);
  #local nz = vnormalize(vcross(nx,ns));
  #local ny = vcross(nz,nx);
  matrix <nx.x,nx.y,nx.z,
          ny.x,ny.y,ny.z,
          nz.x,nz.y,nz.z,
          v1.x,v1.y,v1.z>
#end



> thanks josh.
> i have two identical cylinders. one is somewhere in space (i know xyz of the
> end points), the other one is at the origin and along the x axis (one end point
> is [0,0,0]; the other end point is [length,0,0]). i need to align the second
> one with the first one by means of rotations and translations.
> i'm trying to do it with matrices but any help is appreciated.
> thanks,
> sandra
>
> Josh English wrote:
>
> > Are you saying that the first cylinder has two known endpoints and you want
> > to make a cylinder of the same length along the x axis? In that case, you'd
> > want to calculate vlength(p2 - p1) where p1 and p2 are the endpoints of the
> > first cylinder.
> >
> > If you want the cylinder at the origin to be the same length and go in the
> > same diretion, use <0,0,0> and p2 - p1 as the endpoints.
> >
> > If I'm way off it's because I'm not clear as to what you're asking.
> > Hopefully Peters' suggestion to look at John VanSickles matrix page will
> > help. Perhaps if you posted some code we could see what you want and what
> > you're getting...
> >
> > Josh
> >

> >
> > > hi!
> > > I have a cylinder with known xyz's coordinates and I want to align
> > > (rotate then translate?) a cylinder the same length positioned in
> > > (0,0,0) (length,0,0). I can get the angles around X, Y, and Z axis, but
> > > when I apply these angles to my origin cylinder I don't get the right
> > > alignment.
> > > Thanks in advance for your help!!
> > > sa
> >
> > --
> > Josh English
> > eng### [at] spiritonecom
> > "May your hopes, dreams, and plans not be destroyed by a few zeros."

--
Josh English
eng### [at] spiritonecom
"May your hopes, dreams, and plans not be destroyed by a few zeros."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.