Skip to content
ForCADDocumentation
Browse guide contents ↓

Transform a patch about a pivot

Turn a block through 90° about a vertical line through (1, 0, 0), then move it up by 3 units. Pass one matrix and the two vectors to transform. The rotation helper takes X, Y and Z angles in degrees.

program transform_a_patch
    use forcad, only: rk, nurbs_volume, rotation
    implicit none
    type(nurbs_volume) :: part
    real(rk) :: turn(3,3), corner(3)
    real(rk), parameter :: origin(3) = [1._rk,0._rk,0._rk], shift(3) = [0._rk,0._rk,3._rk]

    call part%set_hexahedron(L=[2._rk,1._rk,1._rk], nc=[2,2,2])
    if (.not. part%err%ok) error stop "Could not build the part"
    turn = rotation(alpha=0._rk, beta=0._rk, theta=90._rk)
    call part%transform(linear=turn, center=origin, translation=shift)
    if (.not. part%err%ok) error stop "Could not transform the part"
    corner = part%cmp_Xg([1._rk,0._rk,0._rk])
    print '(3f8.3)', corner
end program

The corner originally at (2, 0, 0) moves to (1, 1, 3). For a point , the map is , where center is and translation is . Both optional vectors default to zero.

A diagonal matrix scales the coordinate axes. Use a square matrix with the same dimension as the physical coordinates. The operation updates the controls and any previously sampled geometry in place. To move connected members together, call the assembly’s transform with the same arguments.

Studio equivalent. Transform geometry.