Click or drag to resize

Point3dTransform Method

Transforms the present point in place. The transformation matrix acts on the left of the point. i.e.,

result = transformation*point

Namespace:  Rhino.Geometry
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public void Transform(
	Transform xform
)

Parameters

xform
Type: Rhino.GeometryTransform
Transformation to apply.
Examples
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using System;

namespace examples_cs
{
  public class PointAtCursorCommand : Command
  {
    public override string EnglishName { get { return "csPointAtCursor"; } }

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    public static extern bool GetCursorPos(out System.Drawing.Point point);

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    public static extern bool ScreenToClient(IntPtr hWnd, ref System.Drawing.Point point);

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var result = Result.Failure;
      var view = doc.Views.ActiveView;
      if (view == null) return result;

      System.Drawing.Point windows_drawing_point;
      if (!GetCursorPos(out windows_drawing_point) || !ScreenToClient(view.Handle, ref windows_drawing_point))
        return result;

      var xform = view.ActiveViewport.GetTransform(CoordinateSystem.Screen, CoordinateSystem.World);
      var point = new Rhino.Geometry.Point3d(windows_drawing_point.X, windows_drawing_point.Y, 0.0);
      RhinoApp.WriteLine("screen point: ({0})", point);
      point.Transform(xform);
      RhinoApp.WriteLine("world point: ({0})", point);
      result = Result.Success;
      return result;
    }
  }
}
See Also