EDIT: can we use arithmetical operation on vector ? are they defined ?
Modifié par anakin5, 07 janvier 2010 - 09:14 .
Modifié par anakin5, 07 janvier 2010 - 09:14 .
Modifié par Craig Graff, 07 janvier 2010 - 09:47 .
// literal vector v = [1.0, 2.0, 3.0]; // constuctor vector v = Vector(1.0, 2.0, 3.0); // memberwise vector v; v.x = 1.0; v.y = 2.0; v.z = 3.0;
Modifié par Sunjammer, 07 janvier 2010 - 11:24 .
Script squirel_origin valid: 1 Script squirel_origin facing: -180.000152588 Script squirel_origin position: 0.000000 0.000000 0.000000 Script squirel_north valid: 1 Script squirel_north facing: -180.000152588 Script squirel_north position: -6.000000 -4.000000 0.000000 Script squirel_west valid: 1 Script squirel_west facing: 90.000068665 Script squirel_west position: -8.000000 -5.000000 0.000000 Script squirel_south valid: 1 Script squirel_south facing: -0.000022312 Script squirel_south position: -6.000000 -6.000000 0.000000 Script squirel_east valid: 1 Script squirel_east facing: -90.000068665 Script squirel_east position: -4.000000 -5.000000 0.000000It is interesting that EAST is not in fact 270.0 but rather -90.0 which means you would have to normalise before doing a comparison with DIRECTION_EAST constant. Similarly unlike the positions the facings are not an exact number of degrees so you may have to something like:
if(fabs(NormaliseAngle(GetFacing(oTarget)) - DIRECTION_EAST) < 0.001)
0.0 <= angle < 360.0.
Modifié par Sunjammer, 08 janvier 2010 - 01:57 .
float NormalizeAngle( float angle )
{
float result = angle;
while( result > 180 ) result -= 360;
while( result < -180 ) result += 360;
return result;
}
Modifié par FalloutBoy, 08 janvier 2010 - 05:48 .
That is what the function returns however whether or not someone considers that to be the "valid" range depends on their needs. In my example I'm comparing it with constants that are in the range 0.0 to 270.0 so, as stated, I would normalise toFalloutBoy wrote...
Looking at the output it looks like the valid range is actually +/- 180
0.0 <= angle < 360.0as the range -180.0 <= angle < 0.0 isn't appropriate.
whilecondition. It should be:
while(result < -180.0) result += 360.0;
-180.0 <= angle <= 180.0which could cause you problems as you would have two equivalent values. I would suggest using
-180.0 < angle <= 180.0or
-180.0 <= angle < 180.0.
Modifié par Sunjammer, 08 janvier 2010 - 12:28 .
Rest assured it will be going into the Lexicon as soon as I've done some more testing on these functions.Innodil Ath Nathosh wrote...
It would be nice though to DOCUMENT stuff like this on the wiki
Modifié par Craig Graff, 08 janvier 2010 - 04:45 .
Sunjammer wrote...
Incidentally you've omitted a minus operator from your secondwhilecondition. It should be:
Modifié par FalloutBoy, 08 janvier 2010 - 05:53 .