Non-Uniform Scale
Geometric definition
A non-uniform scaling is a transformation that changes the size of a geometry by a certain factor for each or some of the axes. The factor can be defined by a number.
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
# create a rectangle
rectangle = rg.Rectangle3d(rg.Plane.WorldXY, 10, 10)
# do a non-uniform scale transformation
scale = rg.Transform.Scale(rg.Plane.WorldXY, # plane of scaling
1, # x scale factor
2, # y scale factor
3) # z scale factor
# transform the rectangle
rectangle.Transform(scale)
# add the rectangle to the document
sc.doc.Objects.AddRectangle(rectangle)
RhinoScriptSynthax
import rhinoscriptsyntax as rs
# create a rectangle
rectangle_id = rs.AddRectangle(rs.WorldXYPlane(), 10, 10)
# create a scale transformation
scale = rs.Scale(rs.WorldXYPlane(), # the plane on which to scale
1, # the scale factor in x
2, # the scale factor in y
3) # the scale factor in z
# apply the transformation to the rectangle
rs.TransformObject(rectangle_id, scale)
Main methods and properties
Operators
Non-uniform scaling 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 = rs.Scale(rs.WorldXYPlane(), 1, 2, 3)
xform_2 = rs.Scale(rs.WorldXYPlane(), 0.2, 3.6, 4.9)
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
Non-uniform scaling 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:
non_uniform_scale = rs.Scale(rs.WorldXYPlane(), 1, 2, 3)
non_uniform_scale.IsIdentity # Will return True if the transformation is an identity transformation
non_uniform_scale.IsZero # Will return True if the transformation is a zero transformation
non_uniform_scale.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 ⬇️⬇️⬇️🐍