Remapping a point from an initial to other planes in Python?

Hi everybody,

I have a 3D point with an initial plane (e.g. XY plane) and it needs to get “remapped” to several other planes (that are created from normal vectors). The point has specific coordinates (e.g. 1, 2, 0), which should stay the same in all other planes, meaning that its position on the x- and y-axes of the initial plane should be the same on the x- and y-axes of the other planes.

Here’s a simplified example of what I want to do:

Any ideas? Thanks.

Hi P1r4t3boy
You can try the rs.OrientObject() function.like this.

import rhinoscriptsyntax as rs
reference = [plane1.Origin,plane1.XAxis,plane1.YAxis]
target = [plane2.Origin,plane2.XAxis,plane2.YAxis]
a = rs.OrientObject(pt,reference,target)

gh file:Orient.gh (6.1 KB)

3 Likes

Thank you! I’ve figured it out due to your suggestion.

Here’s a rhinocommon example, referring to the above screenshot, if anybody ever runs into the same problem and needs inspiration:

import Rhino.Geometry as rg

from_pt = rg.Point3d(1, 2, 0) # point to remap
from_plane = rg.Plane.WorldXY # plane to remap from
to_plane = rg.Plane.WorldYZ # plane to remap to
xform = rg.Transform.PlaneToPlane(from_plane, to_plane)

to_pt = rg.Point3d(from_pt) # copy point to remap
to_pt.Transform(xform) # transform the copy

a = to_pt # output

Thanks again, Naruto!

Just to add to this, points can also be created from planes:

to_pt = to_plane.PointAt(from_pt.X, from_pt.Y, from_pt.Z)
1 Like