WPF 3D - Need help writing conversion methods between 2D and 3D (Point3DToPoint and PointAndZToPoint
I'm new to WPF 3D, so I may just be missing something obvious, but how do I convert from 3D to 2D and (for a given z location) from 2D to 3D?
Specifically, I need two conversion methods:
Point3DToPoint - If I have an (x, y, z) coordinate in the 3D world, how do I determine the (x, y) coordinate on the projected 2D surface. Method signature:
public Point Point3DToPoint(Point3D point3D)
PointAndZToPoint3D - If I have an (x, y) coordinate on the projected 2D surface and a z location in the 3D world, how do I determine the intersecting (x, y, z) coordinate in the 3D world? Method signature:
public Point3D PointAndZToPoint3D(Point point, double z)
I'd like the 2D coordinate to be the location measured from the upper-left corner of
Viewport3D and the 3D coordinate to be the location relative to the origin (0, 0, 0) of the 3D world.
Note 1: I found this related question, but it only addresses conversion from 3D to 2D (not the reverse), and I'm not sure if the answers are up-to-date.
Note 2: I'm currently using .NET 3.5, but if there are improvements in .NET 4.0 that would help me, please let me know.
© Stack Overflow or respective owner