To be honest other than the 1's, none of the values are particularly close to 1.
evildaddy911 wrote:
d.z = B * cos(a.right) = A * cos(a.up)
This line is wrong, it should be
dz = A * cos(a.right) = B * cos(a.up)
Then we get
code: |
I will use
a = a.right
b = a.up
A = 1 / sqrt( sin(a)^2 + (sin(b) * cos(a) / cos(b))^2 + cos(a)^2 )
B = A * cos(a) / cos(b)
dx = sin(a) * A
dy = sin(b) * B
dz = cos(a) * A = cos(b) * B
Then dx^2 + dy^2 + dz^2 = 1 ( Note that taking the square root is not necessary here)
|
Since Turing is using floating point numbers this might actually work even for angles where cos(b) = 0 or cos(a) = 0 (since Turing can't actually store pi exactly). But you should be very careful.
For example:
evildaddy911 wrote:
B = A * cos(a.right) / cos(a.up)
This is only true if cos(a.up) is not 0, but since Turing doesn't return exactly zero for cos(pi) you're probably ok.