Math Functions

Blitz3D Forums/Blitz3D Programming/Math Functions

Dubious Drewski(Posted 2005) [#1]
Hello all,
I know Blitz3d hides alot of complicated math from the users,
but is there still someone that can help me figure this out?


Baystep Productions(Posted 2005) [#2]
http://blitzbasic.com/Community/posts.php?topic=42657


Matty(Posted 2005) [#3]
Well if all you are after is the dot and cross product of two vectors then they are worked out as follows:

dot product:

assuming that a and b are vectors where a[0] is the x component, a[1] is the y and a[2] is the z, same goes for b[0],b[1],b[2] then you do this:

a.b = a[0]*b[0] + a[1]*b[1] + a[2]*b[2], which returns a scalar value. It is also the same as:

|a||b|cos(theta) where |a|, |b| are the magnitudes of vectors a,b and theta is the angle between them.

for the cross product, using the same notation as above:

a x b = c, where c is a vector with the following values for each component:

c[0]=a[1]*b[2]-a[2]*b[1]
c[1]=a[3]*b[0]-a[0]*b[3]
c[2]=a[0]*b[1]-a[1]*b[0]


Dubious Drewski(Posted 2005) [#4]
Ah Matty, you explain it very nicely. Thank you.
I was wondering about

|a||b|cos(theta)

I've also seen that formula with Sin. I'm assuming the difference
would have something to do with the orientation of the normal? Ie. Up or down?
Am I way off?


Matty(Posted 2005) [#5]
It is always |a||b|cos(theta) for the dot product. Cross product uses sine.