|
|
> > How do I calculate the vertices of a cylinder, given the coordinates
> > of the (center) end-points? I need to draw a disc, and "point it" towards
> > the other end-point, but I'm totally stuck. The net offers plenty of
> > information on how to calculate the normal vector from a surface, but
> > I need the other way around (i.e. a surface on which <0,0,0> points
> > towards <x,y,z>) .. :-/
>
> Well... If you want your disc to be oriented such as its normal points
> to D from its position P, you just have to have its normal colinear to the
> PD vector. For instance, use the PD = D - P vector.
>
> If it's about a cylinder... I don't understand the question.
Hmm, after reading through my post again, I admit it's a bit unclear.
I'll
try again;
- I have two end-points point1=<0,0,0> and point2=<x,y,z>
- I create four vertices around each end-point. For the first, this
would be:
<-thickness,0,0>,<+thickness,0,0>,<0,0,-thickness>,<0,0,+thickness>
- Now I need to rotate these four, so that they are planar (?) to the
second end-point. This is where my math skills fail me miserably..
I tried this approach:
1. rotate vertices atan2(point2.y, point2.z) around the Z axis
2. rotate vertices atan2(point2.z, point2.x) around Y
and it seems to work if both the endpoints all have Z = 0, but that
wont do in the long run.. :-/
It's pretty basic math, but I never got that far in my studies. ;-)
Any help appreciated. Thanks.
Vidar
Post a reply to this message
|
|