Vector math, finding coördinates on a planar between 2 vectors

Posted by Will Kru on Stack Overflow See other posts from Stack Overflow or by Will Kru
Published on 2010-12-21T21:58:10Z Indexed on 2010/12/23 1:55 UTC
Read the original article Hit count: 467

Filed under:
|
|
|
|

I am trying to generate a 3d tube along a spline. I have the coördinates of the spline (x1,y1,z1 - x2,y2,z2 - etc) which you can see in the illustration in yellow. At those points I need to generate circles, whose vertices are to be connected at a later stadium. The circles need to be perpendicular to the 'corners' of two line segments of the spline to form a correct tube. Note that the segments are kept low for illustration purpose.

[apparently I'm not allowed to post images so please view the image at this link] http://img191.imageshack.us/img191/6863/18720019.jpg

I am as far as being able to calculate the vertices of each ring at each point of the spline, but they are all on the same planar ie same angled. I need them to be rotated according to their 'legs' (which A & B are to C for instance).

I've been thinking this over and thought of the following:

  • two line segments can be seen as 2 vectors (in illustration A & B)
  • the corner (in illustraton C) is where a ring of vertices need to be calculated
  • I need to find the planar on which all of the vertices will reside
  • I then can use this planar (=vector?) to calculate new vectors from the center point, which is C
  • and find their x,y,z using radius * sin and cos

However, I'm really confused on the math part of this. I read about the dot product but that returns a scalar which I don't know how to apply in this case.

Can someone point me into the right direction?

[edit] To give a bit more info on the situation:

I need to construct a buffer of floats, which -in groups of 3- describe vertex positions and will be connected by OpenGL ES, given another buffer with indices to form polygons.

To give shape to the tube, I first created an array of floats, which -in groups of 3- describe control points in 3d space.

Then along with a variable for segment density, I pass these control points to a function that uses these control points to create a CatmullRom spline and returns this in the form of another array of floats which -again in groups of 3- describe vertices of the catmull rom spline.

On each of these vertices, I want to create a ring of vertices which also can differ in density (amount of smoothness / vertices per ring).

All former vertices (control points and those that describe the catmull rom spline) are discarded.

Only the vertices that form the tube rings will be passed to OpenGL, which in turn will connect those to form the final tube.

I am as far as being able to create the catmullrom spline, and create rings at the position of its vertices, however, they are all on a planars that are in the same angle, instead of following the splines path.

[/edit]

Thanks!

© Stack Overflow or respective owner

Related posts about math

Related posts about opengl-es