Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Vector cross product #87216
08/23/06 16:56
08/23/06 16:56
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline OP
Expert
Uhrwerk  Offline 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: Uhrwerk] #87217
08/23/06 17:18
08/23/06 17:18
Joined: Oct 2003
Posts: 246
A
Alberto Offline
Member
Alberto  Offline
Member
A

Joined: Oct 2003
Posts: 246
I agree, the dot product function is even much simpler than the cross product one.
They simply forgot it , I guess

Re: Vector cross product [Re: Alberto] #87218
08/24/06 20:50
08/24/06 20:50
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

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: Uhrwerk] #87219
08/25/06 13:14
08/25/06 13:14
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline OP
Expert
Uhrwerk  Offline OP
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Quote:

I know the function is easy to program yourself, but an engine internal function could be much more effective, couldn't it?




Code:
function vec_cross (&ret, &a, &b)
{
ret[0] = a[1] * b[2] - a[2] * b[1];
ret[1] = a[2] * b[0] - a[0] * b[2];
ret[2] = a[0] * b[1] - a[1] * b[0];
}



vec_dot is even simpler:
Code:
function vec_cross (&a, &b)
{
return(a[0] * b[0] + a[1] * b[1] + a[2] * b[2]);
}




Always learn from history, to be sure you make the same mistakes again...
Re: Vector cross product [Re: Uhrwerk] #87220
08/25/06 13:28
08/25/06 13:28
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
but it's better to implement these functions with something else than vars if they are supposed to work correctly with non-normalized vectors too.

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 Offline OP
Expert
Uhrwerk  Offline 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...
Re: Vector cross product [Re: Uhrwerk] #87222
08/25/06 15:16
08/25/06 15:16
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
yes, but the calculations are unsafe because of the limited var range. if the vectors are too long you could get bogus results.


Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1