View Full Version : Normals, planes - major probs!

IainToft

01-24-2002, 02:00 AM

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

IainToft

01-24-2002, 05:10 AM

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

ToolChest

01-24-2002, 05:33 AM

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

IainToft

01-24-2002, 05:49 AM

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

IainToft

01-24-2002, 05:52 AM

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

Furrage

01-24-2002, 07:04 AM

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

ToolChest

01-24-2002, 08:00 AM

Why cant you just use the surface normal?

MrShoe

01-24-2002, 12:29 PM

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.

Jambolo

01-26-2002, 02:53 PM

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.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.