I want to use Mathematica to calculate the projection of a point in 3d to a canvas in 2d.
I need to convert the point
(x,y,z)
to
where k (positive) is the distance between the viewer and the canvas.
Is there any built in function that does it?
Is it critical that it be a built in function, or are you just asking more generally how to do this?
Thanks for your reply. I would prefer a built in function. If you can come up with a better solution than just working with pt[[1]]/(pt[[3]]/k+1) etc. I would be very glad to learn it.
I don’t know what constitutes “better” for you. I’m not sure why operating on a point as you described is a problem. If I were to do it, I’d probably define a function like this:
MyProjection[k_, {x_, y_, z_}] := {x/(z/k + 1), y/(z/k + 1)}
Or maybe:
MyProjection[k_][{x_, y_, z_}] := {x/(z/k + 1), y/(z/k + 1)}
to make currying easier.
Never seen this way of building a function (f[x_][y_]):=…`).
Thanks for a lot for your help.
Thanks! I actually came across the various TransformationFunctions but this one slipped away. That’s what I was looking for.