|
|
|
1 registered members (Grant),
999
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Vector cross product
#87216
08/23/06 16:56
08/23/06 16:56
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
OP
Expert
|
OP
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Hello everybody.
I am missing a function that calculates the crossproduct of two vectors. The function to calculate the dot product is already available in vec_dot(). I know the function is easy to program yourself, but an engine internal function could be much more effective, couldn't it?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Vector cross product
[Re: Alberto]
#87218
08/24/06 20:50
08/24/06 20:50
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Code:
function vec_cross (&a, &b) { temp[0] = a[1] * b[2] - a[2] * b[1]; temp[1] = a[2] * b[0] - a[0] * b[2]; temp[2] = a[0] * b[1] - a[1] * b[0];
return(temp); }
|
|
|
Re: Vector cross product
[Re: ventilator]
#87221
08/25/06 15:07
08/25/06 15:07
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
OP
Expert
|
OP
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
The vetors don't need to be normalized. The cross product returns a vector standing upright on the given twos with the length of the parallelogram, build by the two given vectors.
If you used normalized vectors the length would be always the same. In case you want to implement that, just insert a "vec_normalize(ret,1);" at the end of the function vec_cross.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|
|
|
|