Model.transformmark#

Model.transformmark(collection, r1c1, r1c2, r1c3, r1c4, r2c1, r2c2, r2c3, r2c4, r3c1, r3c2, r3c3, r3c4, r4c1, r4c2, r4c3, r4c4)#

Translates a selection of entities along a vector.

The r1c1- r4c4 are the elements of a 4x4 transformation matrix, in row-column order. This matrix defines the reflection, rotation, scaling and translation applied to the entities.

Parameters:
  • collection (Collection) – The collection containing the entities to transform.

  • r1c1 (double) – Scaling in x-axis. This element contributes in rotation around a point too.

  • r1c2 (double) – Matrix element (row_1,column_2). This element contributes in rotation around a point.

  • r1c3 (double) – Matrix element (row_1,column_3). This element contributes in rotation around a point.

  • r1c4 (double) – Matrix element (row_1,column_4). This element contributes in reflection.

  • r2c1 (double) – Matrix element (row_2,column_1). This element contributes in rotation around a point.

  • r2c2 (double) – Scaling in y-axis. This element contributes in rotation around a point too.

  • r2c3 (double) – Matrix element (row_2,column_3). This element contributes in rotation around a point.

  • r2c4 (double) – Matrix element (row_2,column_4). This element contributes in reflection.

  • r3c1 (double) – Matrix element (row_3,column_1). This element contributes in rotation around a point.

  • r3c2 (double) – Matrix element (row_3,column_2). This element contributes in rotation around a point.

  • r3c3 (double) – Scaling in z-axis. This element contributes in rotation around a point too.

  • r3c4 (double) – Matrix element (row_3,column_4). This element contributes in reflection.

  • r4c1 (double) – Translation in x-axis.

  • r4c2 (double) – Translation in y-axis.

  • r4c3 (double) – Translation in z-axis.

  • r4c4 (double) – Matrix element (row_4,column_4). This element contributes in reflection.

Note

Calculation of transformation matrix:

  1. Calculate the angle in radians.

  2. Construct a matrix to translate from the rotation point to (0,0,0).

  3. Construct a second matrix to handle the actual rotation.

  4. Multiply matrix(step2) X matrix(step3).

  5. Construct a third matrix to translate back to the rotation point.

  6. Multiply matrix(step4) X matrix(step5).

Examples#

Rotate all displayed nodes 30 degrees about the x-axis through the point (0,0,0)#
import hm
import hm.entities as ent

model = hm.Model()

node_collection = hm.CollectionByDisplayed(model, ent.Node)

model.transformmark(
    collection=node_collection,
    r1c1=1,
    r1c2=0,
    r1c3=0,
    r1c4=0,
    r2c1=0,
    r2c2=0.86603,
    r2c3=0.5,
    r2c4=0,
    r3c1=0,
    r3c2=-0.5,
    r3c3=0.86603,
    r3c4=0,
    r4c1=0,
    r4c2=0,
    r4c3=0,
    r4c4=1,
)
Rotate all elements 30 degrees about the x-axis through the point (5,10,6)#
import hm
import hm.entities as ent

model = hm.Model()

node_collection = hm.CollectionByDisplayed(model, ent.Node)

model.transformmark(
    collection=node_collection,
    r1c1=1,
    r1c2=0,
    r1c3=0,
    r1c4=0,
    r2c1=0,
    r2c2=0.86603,
    r2c3=0.5,
    r2c4=0,
    r3c1=0,
    r3c2=-0.5,
    r3c3=0.86603,
    r3c4=0,
    r4c1=0,
    r4c2=4.3397,
    r4c3=-4.1962,
    r4c4=1,
)