Creating a Skew Transformation

I’m trying to figure out how to create a skew or shear transformation since there is not a specific method for doing this within the API.

I’ve actually never encountered this problem before so it will be a topological learning experience.

Does anyone have any examples they might be willing to share?

My intent is to have a specific group (solid) and specify a point on this solid which is the zero point then every other point will be sheared parallel to the Z axis relative to this point. The shearing will only be one dimensional with four possibilities with the directional control: (X, -X, Y or -Y).

I suppose I could write an algorithm that examines each vertex of the group and then translates it to its new Z position, but it would be better if I can simply construct the appropriate transformation and method and approach the problem from that angle.

It would appear that shearing along the Z axis with respect to X or Y is given below:

by the elements hxz and hyz.

I’m assuming that this will shear the geometric body relative to the origin (0,0,0), however is there way to arbitrarily set the X and Y reference point of the shearing to a value other than the origin, if this makes sense?

Transformation operations can be composed (but they are not commutative, so the order is important!).

You are given an operation to shear relative to the origin and an operation to translate relative to the origin.

So you can first translate your preferred shear reference point to the origin, then apply the shear transformation and then translate back.

move_to_origin = Geom::Transformation.translation(reference_point.to_a)
shear = Geom::Transformation.new([1,0,0,0,  0,1,0,0,  2,2,1,0,  0,0,0,1])
move_back = move_to_origin.inverse
transformation = move_to_origin * shear * move_back
sheared_points = points.map{ |p| p.transform(transformation) }
1 Like

Here is a small block of code that tests out the concept:

include Math

rise = 2.0
run = 48.0
tanphi = rise/run
phi = atan(tanphi)
concdepth = 4.0/(cos(phi))

depth = 96.0
width = 96.0
w2 = 48.0
d2 = 48.0

group1 = Sketchup.active_model.active_entities.add_group
entities1 = group1.entities

pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, d2, 0]
pts[3] = [w2, d2, 0]
pts[4] = [w2, depth, 0]
pts[5] = [0, depth, 0]

new_face1 = entities1.add_face pts
new_face1.pushpull concdepth

move_to_origin = Geom::Transformation.new([0,96.0,0])
move_back = move_to_origin.inverse
shear_tr = Geom::Transformation.new([1,0,0,0,  0,1,tanphi,0,  0,0,1,0,  0,0,0,1])

total_tr = move_to_origin * shear_tr * move_back

group1.transform! total_tr

A search for shear instead of skew includes:

2 Likes