Built-in function for projecting a point in 3D to 2D?

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.

You can achieve this with LinearFractionalTransform:

LinearFractionalTransform[
  {{{1, 0, 0},
    {0, 1, 0}},
   {0, 0},
   {0, 0, 1/k},
   1}][{x, y, z}]

(* {x/(1 + z/k), y/(1 + z/k)} *)

Is it worth the hassle is another question…

This corresponds to the following TransformationFunction:

Thanks! I actually came across the various TransformationFunctions but this one slipped away. That’s what I was looking for.