Reputation: 153
I'm trying to build a thing that renders point cloud data stored in a specific way to a canvas using Javascript.
The data is stored as (JSON, where -> represents a range of values including the two extremes)
{"xangle":-Math.PI*2 -> Math.PI*2,"yangle": -Math.PI*2 -> Math.PI*2,"disntancefromorigin":10,"colour":blue}
I've been having some trouble working out what the maths should be for turning the xangle, which represents the angle away from the x axis the line is and the yangle, which is the same but from the yaxis, and the distance from the origin into a "3d" point.
I've been running code which generates a large array of points the same distance from the origin with the same distance and trying to manually brute force the algorithm till i got it right - but that didn't help much.
thanks for any help, if I've not made something clear or you want to see the code just ask.
EDIT: I should add, I'm just going for an Orthographic representation (at least till I can get that working)
Upvotes: 0
Views: 386
Reputation: 12926
r = distancefromorigin
y=r*cos(yAngle)
x=r*cos(xAngle)
z=+-r*sqrt( 1-cos^2(yAngle) - cos^2(xAngle) )
Edit: Last equation is from x^2 + y^2 + z^2 = r^2
You cannot say if you have to pick + or - because your problem is ill defined!
Upvotes: 1