00:00
00:00
FlyingColours

Age 26, Male

Joined on 7/3/11

Level:
6
Exp Points:
330 / 400
Exp Rank:
> 100,000
Vote Power:
4.66 votes
Rank:
Civilian
Global Rank:
73,042
Blams:
0
Saves:
91
B/P Bonus:
0%
Whistle:
Normal
Trophies:
1
Medals:
347

The Strangeness of the Flash Coordinates

Posted by FlyingColours - July 6th, 2012


I made the following function in a static class yesterday:

public static function determineGradient(type:String, a:Number, b:Number, c:Number, d:Number):Number{
var gradient:Number;
if(type = "coordinates"){
gradient = (d - b) / (c - a);
} else if(type = "rr" ){
gradient = a / b;
}
return gradient;
}

The idea was that the 'type' string would determine whether a, b, c, d would be coordinates or the rise and run. In the former case, I would use the coordinates to produce the slope, and in the latter case, I would divide the vertical rise by the horizontal run. Unfortunately, I had made a grave mistake.

I remembered that the Flash coordinate plane doesn't work like normal Cartesian planes. Instead of increasing upwards, the y-axis increases downwards in Flash. Therefore, all the y-coordinates entered will be the additive inverses of the real y-coordinates! The resulting gradient is thus the additive inverse of the true gradient. This means that the resulting gradient describes the slope of a line which has the same steepness as the original line, but slopes in the opposite direction!

This can be explained easily because by inverting the y-coordinates, the line is reflected along the x-axis. When this happens, the resulting line must be sloping in the opposite direction as the original line. It's no rocket science, but I feel good about discovering this. :)


Comments

Comments ain't a thing here.