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
4 registered members (AndrewAMD, fogman, Grant, juanex), 972 guests, and 7 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
if-term problem #253891
02/27/09 15:02
02/27/09 15:02
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
Hello,

I want to use an if-term where I compare a vector:

how do I do this? I have already tried out:
VECTOR* vector1;

if (vector1.x < 1)
...

but it does not work!


new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: if-term problem [Re: MPQ] #253892
02/27/09 15:06
02/27/09 15:06
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
vector1[0]


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: if-term problem [Re: Michael_Schwarz] #253893
02/27/09 15:13
02/27/09 15:13
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
If you want to compare to the magnitude of a vector you can use vec_length.

And if vector1 is a local vector, you can omit the asterik (*) in its declaration.

Re: if-term problem [Re: Saturnus] #253907
02/27/09 16:06
02/27/09 16:06
Joined: Jan 2009
Posts: 86
Brasil - RS
D
DiegoFloor Offline
Junior Member
DiegoFloor  Offline
Junior Member
D

Joined: Jan 2009
Posts: 86
Brasil - RS
Complementing the Kombucha's answer, what exactly do you want to compare? What you did there works, but it's only comparing the x component of vector1.

Re: if-term problem [Re: DiegoFloor] #253911
02/27/09 17:28
02/27/09 17:28
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
yeah, I only want to use the x-component of the term

like: if the x-value of the vector is under 10, do sth. (thats waht i want ;))

vec_length is not what i need because I only want to get the x-value of the vector and not the whole xyz-vector

Last edited by MPQ; 02/27/09 17:35.

new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: if-term problem [Re: MPQ] #253960
02/27/09 23:52
02/27/09 23:52
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
I'll clarify more:

use vector1[0] instead of vector1.x


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: if-term problem [Re: Michael_Schwarz] #253967
02/28/09 01:02
02/28/09 01:02
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
AND as long as the vector is being correctly declares and initialised,
[b]if (vector1.x < 1)[.b] should work fine for just testing the X portion.

To clarify the defining,
Code:
VECTOR* vector1 = { x=0; y=0; z=0; }    //if OUTSIDE a function (global variable/vector)

VECTOR vector1;       //needs both these lines in this order
vec_zero(vector1);    //  if inside a function(local variable/vector)



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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