math operator ...
many times i have seen somthing incaplulated with ''|'' what does this meen ?
*like : |A| *
or
* |V| *
can anybody explain this ?
It means the absolute value of the value encapsulated between the |'s. That is, |V| == abs(V) where
float abs(float x){
if (x<0) return -x;
else return x;
}
In C/C++ code, | means bitwise or (|| = logical or).
Edit: woops... the next poster is right
[edited by - Kurioes on January 5, 2003 2:05:39 PM]
float abs(float x){
if (x<0) return -x;
else return x;
}
In C/C++ code, | means bitwise or (|| = logical or).
Edit: woops... the next poster is right
[edited by - Kurioes on January 5, 2003 2:05:39 PM]
Ok, I am a bit tired, so my mind might be messed up, but isn''t you abs() function a bit weird.
It could as well just say "return x;" since that is all it does...
Isn''t this the correct way:
Simplier put, it is as this:
x = 10
|x| = 10
y = -5
|y| = 5
If the number is negative, then just remove the "-"-sign.
The absolute value is actually just the size of the number, not considering which direction it is facing (well, mostly we just delas with 1 dimension, and then you have negative and positive numbers, but if you count in 2 dimensions, then |x| would be the size of your 2d-value (actually, it is the length of a line...).
It could as well just say "return x;" since that is all it does...
Isn''t this the correct way:
float abs(float x){if(x < 0) return -x;else return x;}
Simplier put, it is as this:
x = 10
|x| = 10
y = -5
|y| = 5
If the number is negative, then just remove the "-"-sign.
The absolute value is actually just the size of the number, not considering which direction it is facing (well, mostly we just delas with 1 dimension, and then you have negative and positive numbers, but if you count in 2 dimensions, then |x| would be the size of your 2d-value (actually, it is the length of a line...).
Also note that if V is a vector, then |V| is the length of the vector.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
December 23, 2002 06:13 PM
It also means the length of a vector, ie if you have a vector:
v(x, y, z)
then |v| =
sqrt( x^2 + y^2 + z^2 )
Which is defined as the absolute value operation on a vector, it''s just a bit more of a calculation than the above answer (which is correct) for a scalar number..
v(x, y, z)
then |v| =
sqrt( x^2 + y^2 + z^2 )
Which is defined as the absolute value operation on a vector, it''s just a bit more of a calculation than the above answer (which is correct) for a scalar number..
Mathematically, |V| is equivalent to sqrt(V2).
Cheers,
Timkin
[edited by - Timkin on January 5, 2003 5:55:34 PM]
Cheers,
Timkin
[edited by - Timkin on January 5, 2003 5:55:34 PM]
quote:
Original post by Timkin
Mathematically, |V| is equivalent to sqrt(V2).
[edited by - Timkin on January 5, 2003 5:55:34 PM]
This is only true for real numbers.
quote:
Original post by Predictor
This is only true for real numbers.
Okay... I had assumed we WERE discussing reals (scalar and vector), as opposed to say complex numbers or matrices.
I would have assumed that the distinction was rather obvious and didn''t need further clarification!
Timkin
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement