Trying to understand parameters for Shear transformation


#1

I am not able to wrap my head around setting up a shear transformation…

The xform wants a base plane and 3 “scale” vectors… Base plane, OK, but how do the scale vectors work?

Let’s say I want to take a simple cube with the lower left corner at the World origin, and shear it over 45° along the +Y axis (looking at it in right view, that would be a shear angle of -45° if one used the shear command)… I’ve tried a few things, but I cannot figure out how to set this up yet… I can manage to scale along one or more axes, but not shear over… Do I have to somehow align the base plane to the shear axis?

Thanks, --Mitch


#2

Scrolling half-ways down this page may perhaps illustrate what you’re looking for?

Look up the following text “What do linear transformations in two dimensions look like?”. The three or four videos that follows demonstrates shear effects.

// Rolf


#3

Sorry, no… Looking for what I might need to input in Rhino

–Mitch


#4

Ah, OK. I should have read more carefully.

// Rolf


#5

I understand something like that
Vec 1 = 1: 1 (Scale factor)
FirstArray X = Direction and size for X
SecondArray Y = direction and size for Y, x element in this array determines Your wanted angle.
Third Z = direction and size for Z

Example Angle 20 = ArrayY = x= tan(20) x= 0.3639
Example Angle 45 = ArrayY = x= tan(45) x= 1


Understanding Transform.Shear
#6

Hi Mitch

I see that rhinoscriptsyntax.XformShear() docs talk about ‘scale factors’,
then I think that the coordinates of the object (relative to the reference plane) gets multiplied by the vectors and then summed to obtain the target points … maybe …

This seems to work:

import Rhino
import scriptcontext

def main():
  rep = Rhino.Geometry.Brep.CreateFromBox(
      Rhino.Geometry.BoundingBox(
        Rhino.Geometry.Point3d.Origin,
        Rhino.Geometry.Point3d( 100.0, 100.0, 100.0 ) ) )
  xfo = Rhino.Geometry.Transform.Shear(
      Rhino.Geometry.Plane.WorldXY,
      Rhino.Geometry.Vector3d( 1.0, 0.0, 0.0 ),
      Rhino.Geometry.Vector3d( 0.0, 1.0, 0.0 ),
      Rhino.Geometry.Vector3d( 0.0, 1.0, 1.0 ) )
  rep.Transform( xfo )
  scriptcontext.doc.Objects.AddBrep( rep )
  scriptcontext.doc.Views.Redraw()

main()

Regards

EDIT

… which I think is what Eddi already said … :blush:


Understanding Transform.Shear
#7

Yep, finally I figured it out, at first I thought the shear vector would be a vector from the origin to the result of adding the individual X, Y and Z vectors…

Thanks guys… --Mitch


#8

Ok but do not forget
If you scale Y/Vec other than 1, for a wanted angle you must also multiply the tangent xVal from Y/Vec by this factor

-Regards