Click or drag to resize
AB4D logo

BaseCameraPoint3DTo2D Method (Point3D, Size)

Converts a Point3D to the Point 2D on the screen with custom Viewport3D size (no need that this Camera class is connected to real Viewport3D)

Namespace:  Ab3d.Cameras
Assembly:  Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 10.1.8147.1045
Syntax
C#
public Point Point3DTo2D(
	Point3D point3D,
	Size viewportSize
)

Parameters

point3D
Type: System.Windows.Media.Media3DPoint3D
Original Point3D
viewportSize
Type: System.WindowsSize
Size of the Viewport3D

Return Value

Type: Point
Point2D in the screen coordinates
Remarks

Point3DTo2D converts a Point3D to the Point 2D on the screen with custom Viewport3D size (no need that this Camera class is connected to real Viewport3D)

The matrix to convert 3D point to 2D point is calculated from the used Ab3d.Camera. The matrix value is cached and is only recalculated when the camera is changed.

If the matrix to convert 3D point to 2D point cannot be calculated (for example if TargetViewport3D is not set), the returned point will be Point(double.NaN, double.NaN).

With this method you can convert 3D coordinates to 2D space without creating read Viewport3D and attaching the camera to it. The following example shows how to do that:

Examples
var targetPositionCamera = new Ab3d.Cameras.TargetPositionCamera()
{
    Heading = 30,
    Attitude = -20,
    Distance = 200
};

var point2D = targetPositionCamera.Point3DTo2D(new Point3D(100, 100, 100), new Size(200, 100));
See Also