Plane-To-Plane Transformation
Geometric definition
A plane-to-plane transformation is a transformation that moves a geometry from one plane to another. The transformation can be defined by a plane. This is extremely useful as it allows to move geometries from one plane to another without having to calculate the transformation matrix.
How to add
As often is possible in Rhino to use either RhinoCommons
or RhinoScriptSynthax
to add a point to the Rhino workspace. Here are the two methods:
RhinoCommons
import Rhino.Geometry as rg
import scriptcontext as sc
# source plnae
source_pln = rg.Plane.WorldXY
# target plane (e.g. defined by 3 points)
target_pln = rg.Plane(rg.Point3d(10, 10, 0), # origin
rg.Point3d(8, 5, 23), # x axis
rg.Point3d(12, 4, 0)) # y axis
# create a rectangle
rectangle = rg.Rectangle3d(source_pln, 10, 10)
# do a plane-to-plane transformation
xform_pln_2_pln = rg.Transform.PlaneToPlane(source_pln, target_pln)
# transform the rectangle
rectangle.Transform(xform_pln_2_pln)
# add the rectangle to the document
sc.doc.Objects.AddRectangle(rectangle)
RhinoScriptSynthax
import rhinoscriptsyntax as rs
# source plane
source_pln = rs.WorldXYPlane()
# target plane (e.g. defined by 3 points)
target_pln = rs.PlaneFromPoints([10, 10, 0], # origin
[8, 5, 23], # x axis
[12, 4, 0]) # y axis
# create a rectangle
rectangle_id = rs.AddRectangle(source_pln, 10, 10)
# do a plane-to-plane transformation
xform_pln_2_pln = rs.XformChangeBasis(source_pln, target_pln)
# transform the rectangle
rs.TransformObject(rectangle_id, xform_pln_2_pln, copy=False)
Main methods and properties
Operators
plane-to-plane as all the other transformations have a set of operators that can be used to perform to combine transformations (also different kinds, e.g.: translation with rotation). Here are the main ones:
xform_1 = rg.Transform.PlaneToPlane(source_pln1, target_plnA)
xform_2 = rg.Transform.PlaneToPlane(source_pln2, target_plnB)
xform_3 = xform_1 * xform_2 # Will combine the two transformations
⚠️ Note that the order of the transformations is important. In the example above the first transformation will be applied first and the second transformation will be applied second. ⚠️
Properties
plane-to-plane as all the other transformations have a set of properties that can be used to retrieve information about the transformation. Here are the main ones:
pln_2_pln = rg.Transform.PlaneToPlane(source_pln, target_pln)
pln_2_pln.IsIdentity # Will return True if the transformation is an identity transformation
pln_2_pln.IsZero # Will return True if the transformation is a zero transformation
pln_2_pln.IsValid # Will return True if the transformation is valid
🛠 Exercises
Starting file:
01: 🦏⬇️⬇️⬇️ Download the file here ⬇️⬇️⬇️🦏 01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍
Solution:
01: 🦏⬇️⬇️⬇️ Download the file here ⬇️⬇️⬇️🦏 01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍