I have a central function that I use to project 3D {x, y, z} coordinates onto a 2D picture plane. For a number of reasons, I can’t use any of Processing’s 3D functionality for what I’m doing.
I’m hoping to find a way to depth sort all points so that I can then use a cropping function to remove anything that’s behind something else. In order to do that, I need to know the distance between each point and from the camera, and I don’t know where the camera is in {x, y, z}.
This is the simple function I’m using to project 3D points onto the 2D picture plane. It takes as inputs:
the point to project: float[] pos = {x, y, z}
rotation angle of the camera
elevation angle of the camera
x & y origin points
Can anyone point me in the direction of determining the position of the camera/eye? This kind of math does not come natural to me.
I have all the other pieces in place, and I just need to automate the depth sorting before cropping.
Camera distance isn’t the best way to put it. Because this is orthographic/axonometric projection, there isn’t a singular viewpoint the way there would be with point perspective projection.
What I’m looking for is the distance from each point to be projected through the projection plane to the viewpoint plane.
as Chrisir guessed, I’m doing everything by hand. I’m creating and cropping line work, and because of that, none of the built-in 3D projection functionality completely suits my workflow from the Processing sketch onwards through my process.
I’ll try and strip what I’m doing down to a minimal example. It might take me until the morning to get that together.
I made a quick semi-accurate illustration of what I’m talking about, and stripped down what I’m doing to a simple sketch example.
I need to figure out the depth order of lines in the scene, so that I can crop the lines in that order. It’s the Painter’s Algorithm problem.
I’m hoping that I can determine the distance from each {x, y, z} point, along the ground plane in line perpendicular to the orientation of the picture plane, to the vertically perpendicular point from the ground plane to the bottom edge of the picture plane. I hope that makes some sense.
That distance is shown by a red line in my illustration.