# Thread: Normals, planes - major probs!

1. ## Normals, planes - major probs!

I am attempting to construct a roller coaster simulator. Each track piece is defined by a right handed pair of vectors. A direction vector, and up vector and a normal vector. I can use the direction vector ok, but how do I calculate the up vector from the directional vector?

Once this is cracked I then want to rotate the up vector around directional vector to get track pieces to bank.
http://www.angelfire.com/or3/w0042625/roller.jpg
http://www.angelfire.com/or3/w0042625/roller2.GIF

Cheers
Iain
i.toft@uea.ac.uk

2. ## Re: Normals, planes - major probs!

Copy and past the above links into a browser window, don't click as they won't work!

3. ## Re: Normals, planes - major probs!

Is the 'Up' vector straight into the sky or 90 degrees off of the surface of the track?

4. ## Re: Normals, planes - major probs!

At the moment is fixed at (0, 1, 0) however I need to calculate it according to the directional vector so it is always at a right angle to the directional vector. Reason for this is for lighting and also so the first person cam can take the up vector for each track piece.
Iain

5. ## Re: Normals, planes - major probs!

If you look at that second picture it should explain what I need, copy and paste the link into a browser window to get it to work(damn angel fire).
Iain

6. ## Re: Normals, planes - major probs!

To keep the Up vector perpendicular to the Front vector use the following. This should work so long as the front vector has not rotated so much that it is parallel to the CurrentUp vector.

Right = Front x CurrentUp
NewUp = Right x Front
Normalise NewUp

Rotating it around the Front vector by an angle A is given by the following. |CurrentUp| is the length of the CurrentUp vector. However, if you use this you will have to normalise / correct the length of the NewUp vector after a couple thousand rotations. The calculations give rounding errors after a while.

NewUp = CurrentUp * cos(A) + NormalisedRight * sin(A) * |CurrentUp|

There might be faster ways to do this. If anyone knows share it with us

7. ## Re: Normals, planes - major probs!

Why cant you just use the surface normal?

8. ## Re: Normals, planes - major probs!

I dont really understand what you want, but to get a vector perpendicular to 2 other vectors you need to Cross product those 2 vectors to get it.

9. ## Re: Normals, planes - major probs!

Here's my first suggestion: Rename your vectors! Use direction, left, and up (or normal). A "normal" vector is a specific vector which is not the same as your "normal" vector. You will save yourself (and everybody else) a lot of confusion.

If you have two vectors, you can get the third using the cross-product.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•