Therefore, Math.atanatan2(y1, x1)
would work just the same as Math.atanatan2(dy, dx)
.
So far, your function can be simplified to the following. Since you repurposed angle
twice, I need to disambiguate them as alpha
, beta
, and theta
for the purpose of this discussion.
It would be nice to say Math.atanatan2(Math.sin(alpha), something)
instead of Math.atanatan2(-Math.sin(alpha), something)
. Let's move the negation into the denominator then, for var theta = Math.atanatan2(Math.sin(alpha), -x1)
.
Therefore, Math.atan(y1, x1)
would work just the same as Math.atan(dy, dx)
.
So far, your function can be simplified to the following. Since you repurposed angle
twice, I need to disambiguate them as alpha
, beta
, and theta
for the purpose of this discussion.
It would be nice to say Math.atan(Math.sin(alpha), something)
instead of Math.atan(-Math.sin(alpha), something)
. Let's move the negation into the denominator then, for var theta = Math.atan(Math.sin(alpha), -x1)
.
Therefore, Math.atan2(y1, x1)
would work just the same as Math.atan2(dy, dx)
.
So far, your function can be simplified to the following. Since you repurposed angle
twice, I need to disambiguate them as alpha
, beta
, and theta
for this discussion.
It would be nice to say Math.atan2(Math.sin(alpha), something)
instead of Math.atan2(-Math.sin(alpha), something)
. Let's move the negation into the denominator then, for var theta = Math.atan2(Math.sin(alpha), -x1)
.
- 145.6k
- 22
- 190
- 479
But wait, there's more! The period of There's a mysterious correction from alpha
to beta
, and the tangent functioncosine expression is πcomplicated. Therefore
Let's start with Math.sin(beta)
. That's Math.sin(-alpha)
, there's no point in "correcting"or -Math.sin(alpha)
by subtracting π.
It would be nice to say Math.atan(Math.sin(alpha), something)
instead of Math.atan(-Math.sin(alpha), something)
. Let's move the negation into the denominator then, for var theta = Math.atan(Math.sin(alpha), -x1)
.
Can we simplify -x1
?
-x1 = -Math.cos(beta - ISO)
= Math.cos(beta - ISO + 180°)
= Math.cos(alpha - 180° - ISO + 180°)
= Math.cos(alpha - ISO)
But wait, there's more! The period of the tangent function is π. Therefore, there's no point in "correcting" alpha
by subtracting π.
But wait, there's more! There's a mysterious correction from alpha
to beta
, and the cosine expression is complicated.
Let's start with Math.sin(beta)
. That's Math.sin(-alpha)
, or -Math.sin(alpha)
.
It would be nice to say Math.atan(Math.sin(alpha), something)
instead of Math.atan(-Math.sin(alpha), something)
. Let's move the negation into the denominator then, for var theta = Math.atan(Math.sin(alpha), -x1)
.
Can we simplify -x1
?
-x1 = -Math.cos(beta - ISO)
= Math.cos(beta - ISO + 180°)
= Math.cos(alpha - 180° - ISO + 180°)
= Math.cos(alpha - ISO)
But wait, there's more! There's a mysterious correction from alpha
to beta
, and The period of the cosine expressiontangent function is complicated.
Let's start with Math.sin(beta)
. That's Math.sin(-alpha)
, or -Math.sin(alpha)
.
It would be nice to say Math.atan(Math.sin(alpha), something)
instead of Math.atan(-Math.sin(alpha), something)
π. Let's move the negation into the denominator then Therefore, forthere's no point in "correcting" var theta = Math.atan(Math.sin(alpha), -x1)
by subtracting π.
Can we simplify -x1
?
-x1 = -Math.cos(beta - ISO)
= -Math.cos(alpha - 180° - (116° - 90°))
= -Math.cos(alpha - 154°)
= Math.cos(180° + (alpha - 154°))
= Math.cos(alpha - 26°)
public static inline var ISO:Float = 0.45378560412226;45378560551; // = 26(116-90) / 180 * PI
function convert(angle:Float):Float
{
return Math.atan2(Math.sin(angle), Math.cos(angle - ISO));
}
Not only is the code more efficient, it's also less mysterious: the transformation is rotatingtaking the x-coordinate of each point as if it were rotated 26° clockwise!
But wait, there's more! There's a mysterious correction from alpha
to beta
, and the cosine expression is complicated.
Let's start with Math.sin(beta)
. That's Math.sin(-alpha)
, or -Math.sin(alpha)
.
It would be nice to say Math.atan(Math.sin(alpha), something)
instead of Math.atan(-Math.sin(alpha), something)
. Let's move the negation into the denominator then, for var theta = Math.atan(Math.sin(alpha), -x1)
.
Can we simplify -x1
?
-x1 = -Math.cos(beta - ISO)
= -Math.cos(alpha - 180° - (116° - 90°))
= -Math.cos(alpha - 154°)
= Math.cos(180° + (alpha - 154°))
= Math.cos(alpha - 26°)
public static inline var ISO:Float = 0.45378560412226; // = 26 / 180 * PI
function convert(angle:Float):Float
{
return Math.atan2(Math.sin(angle), Math.cos(angle - ISO));
}
Not only is the code more efficient, it's also less mysterious: the transformation is rotating the x-coordinate of each point as if it were rotated 26° clockwise!
But wait, there's more! The period of the tangent function is π. Therefore, there's no point in "correcting" alpha
by subtracting π.
public static inline var ISO:Float = 0.45378560551; // = (116-90) / 180 * PI
function convert(angle:Float):Float
{
return Math.atan2(Math.sin(angle), Math.cos(angle - ISO));
}
Not only is the code more efficient, it's also less mysterious: the transformation is taking the x-coordinate of each point as if it were rotated 26° clockwise!