Hi there. To start with I will admit that maths and physics are not my strongest point, however I do have some basic knowledge of vector maths.
I'm currently writing a 3D program where I need to generate the vertices for several triangles to make a cuboid. The data I have to generate from this is a list of points and vectors.
For example, I have 3 points:
position: (xyz) | vector: (xyz)
-----------------------------------------
0,0,0 | 1,0,0
2,0,0 | 0,1,0
2,2,0 | 0,1,0
Here is the graphical representation:
Y
^ ^
| |
| 0
| ^
| |
| |
|0---->0
+-------------------X
\Z
From these 3 points and directions, I am attempting to work out 4 vertices, to make a 3D 6 sided shape. I won't worry about the process of generating individual triangles from these 4 vertices as I can probably cope with that.
In my program so far I have a special case for the first and last points, where all the vertices must be the same distance from the point (0.5f), but on the middle points (only one specified for this example for simplicity) they will always be at right angles, so the vertices need to be on a plane of 45 degree:
^
|
. 0 .
^
|
. . |
0--->0
. .
What I am having problems with is generating the plane mathematically and then knowing the co-ordinates in 3D of the vertices. I may be able to do it using pure program logic, but it would be inefficient if there's a mathematical route to go.
Sorry if its hard to know what I want. But if you were to imagine that last diagram mirrored on the X axis, then the plane of the verticis on the right would be different:
. .
0-->0
. . |
|
\/
. 0 .
|
|
\/
Since the actual points I will be generating will be 3D I am only concerned about generating the 4 vertices around the current point, as I will have access to the previous point/vert data. All the vertices need to be 0.5 units away from the point.
Any ideas on how to go about doing this, or just general pointing in the right direction? I've tried a few things involving the dot product and stuff, but I was just scribbling on paper and not really knowing what I am doing. Any help in this problem will be appreciated and rating++ :)
If you need anything explained further please ask and i will do my best.
Thanks
Jason