Ejemplo n.º 1
0
 internal static Point Point3DInViewport3D(Viewport3D viewport, Matrix3D viewportToWorld, Point3D point)
 {
   Camera camera = viewport.Camera;
   Point3D point1 = viewportToWorld.Transform(point);
   Point3D point3D = Helper3D.CameraRotationTranslationMatrix(camera).Transform(point1);
   Point4D point2 = new Point4D(point3D.X, point3D.Y, point3D.Z, 1.0);
   Point4D point4D = AdornedToolBehavior3D.ProjectionMatrix(viewport.ActualWidth, viewport.ActualHeight, camera).Transform(point2);
   Point point3 = Math.Abs(point4D.W) >= 0.0 / 1.0 ? new Point(point4D.X / point4D.W, point4D.Y / point4D.W) : new Point(0.0, 0.0);
   return new Point((point3.X + 1.0) * viewport.ActualWidth / 2.0, viewport.ActualHeight * ((1.0 - point3.Y) / 2.0));
 }
Ejemplo n.º 2
0
 internal static Point3D ProjectionPoint3DTranslatedToMatchingOrthographicPosition(Viewport3D viewport, Matrix3D pointToWorldTransform, OrthographicCamera ortho, Point3D point)
 {
   Camera camera = viewport.Camera;
   Point3D point1 = pointToWorldTransform.Transform(point);
   Point3D point3D = Helper3D.CameraRotationTranslationMatrix(camera).Transform(point1);
   Point4D point2 = new Point4D(point3D.X, point3D.Y, point3D.Z, 1.0);
   Point4D point4D1 = AdornedToolBehavior3D.ProjectionMatrix(viewport.ActualWidth, viewport.ActualHeight, camera).Transform(point2);
   Point4D point3 = new Point4D(point4D1.X / point4D1.W, point4D1.Y / point4D1.W, 0.0, 1.0);
   Matrix3D matrix3D1 = AdornedToolBehavior3D.ProjectionMatrix(viewport.ActualWidth, viewport.ActualHeight, (Camera) ortho);
   if (Math.Abs(matrix3D1.Determinant) > 1E-16)
     matrix3D1.Invert();
   Point4D point4D2 = matrix3D1.Transform(point3);
   Point3D point4 = new Point3D(point4D2.X / point4D2.W, point4D2.Y / point4D2.W, point3D.Z);
   Matrix3D matrix3D2 = Helper3D.CameraRotationTranslationMatrix((Camera) ortho);
   matrix3D2.Invert();
   return matrix3D2.Transform(point4);
 }