Basic usage of geo3d

[2]:
from geo3d import frame_wizard, Vector, Point, RotationMatrix, Frame, transformation_between_frames

Frame creation

Manual Frame cration

Manually create frame from given rotation Euler angles and translation vector.

[4]:
rot = RotationMatrix.from_euler_angles('xyz', [-70.89339465, -74.20683095,  45], degrees=True)
vec = Vector([3,4,6])
Frame(rot,vec)
[4]:
rotation matrix Fixed angles
(xyz, extr., deg.)
Euler angles
(xyz, intr., deg.)
translation
0.192450090.41147560-0.89087081
0.192450090.874385650.44543540
0.96225045-0.257172250.08908708
θx-70.89339
θy-74.20683
θz45.00000
θx-78.69007
θy-62.98288
θz-64.93417
x3.00000
y4.00000
z6.00000

The Frame Wizard

Create two frames using a Frame Wizard (comparable to the one in Spatial Analyzer). Frames are defined as transformations starting from a unit frame (no translation and rotation).

[5]:
# rotation only from UnitFrame
fa = frame_wizard(Vector([1, 1, 0]), Vector([1, -1, 0]), "x", "y", origin=[0, 0, 0])
# translation only from UnitFrame
fb = frame_wizard(Vector([1, 0, 0]), Vector([0, 1, 0]), "x", "y", origin=[1, 1, 4])
# rotation and translation from UnitFrame
fc = frame_wizard(Vector([1, 1, 0]), Vector([1, -1, 0]), "x", "y", origin=[1, 1, 4])
[6]:
fa
[6]:
rotation matrix Fixed angles
(xyz, extr., deg.)
Euler angles
(xyz, intr., deg.)
translation
0.707106780.707106780.00000000
0.70710678-0.707106780.00000000
0.00000000-0.00000000-1.00000000
θx180.00000
θy0.00000
θz45.00000
θx180.00000
θy0.00000
θz-45.00000
x0.00000
y0.00000
z0.00000
[7]:
print(fb)
<Frame instance at 4508522128>
rotation
[[ 1. -0.  0.]
 [ 0.  1.  0.]
 [ 0. -0.  1.]]
Fixed angles (xyz, extrinsic, deg.)
[0. 0. 0.]
Euler angles (XYZ, intrinsic, deg.)
[0. 0. 0.]
translation
[1 1 4]

They have a rotation and translation component:

[8]:
fc.translation
[8]:
x1.00000
y1.00000
z4.00000
[9]:
fc.rotation
[9]:
0.707106780.707106780.00000000
0.70710678-0.707106780.00000000
0.00000000-0.00000000-1.00000000

The rotation can be expressed as Euler angles.

[10]:
fc.euler_angles('xyz', degrees='True')
[10]:
array([180.,   0.,  45.])

Frame from 4x4 matrix string

Construct Frame from 4x4 matrix (SA style)

[11]:
frame_from_SA = Frame.from_SA_pastable_string(
    "0.0000000344 0.0000002614 -1.0000000000 634.9997932029 -0.1305702435 -0.9914390609 -0.0000002637 784.0319609308 -0.9914390609 0.1305702435 0.0000000000 747.5060850385 0.0000000000 0.0000000000 0.0000000000 1.0000000000 "
)
frame_from_SA
[11]:
rotation matrix Fixed angles
(xyz, extr., deg.)
Euler angles
(xyz, intr., deg.)
translation
0.000000030.00000026-1.00000000
-0.13057024-0.99143906-0.00000026
-0.991439060.130570240.00000000
θx90.00000
θy82.49745
θz-89.99998
θx89.99689
θy-89.99998
θz-82.50056
x634.99979
y784.03196
z747.50609

Convert Frame back to 4x4 matrix string

[12]:
print(frame_from_SA.SA_pastable_string())
0.000000034400 0.000000261400 -1.000000000000 634.999793202900
-0.130570243500 -0.991439060900 -0.000000263700 784.031960930800
-0.991439060900 0.130570243500 0.000000000000 747.506085038500
0.000000000000 0.000000000000 0.000000000000 1.000000000000

Frame to frame transformations

A frame can be expressed in a different frame.

[13]:
fb.express_in_frame(fa)
[13]:
rotation matrix Fixed angles
(xyz, extr., deg.)
Euler angles
(xyz, intr., deg.)
translation
0.707106780.707106780.00000000
0.70710678-0.707106780.00000000
0.000000000.00000000-1.00000000
θx180.00000
θy0.00000
θz45.00000
θx180.00000
θy0.00000
θz-45.00000
x1.41421
y0.00000
z-4.00000

This yields the frame-to-frame transformation from fA to fB, represented in fA.

The same frame-to-frame transformation matrix, but given in the original (unit) frame is

[14]:
transformation_between_frames(fa, fb)
[14]:
rotation matrix Fixed angles
(xyz, extr., deg.)
Euler angles
(xyz, intr., deg.)
translation
0.707106780.707106780.00000000
0.70710678-0.707106780.00000000
0.000000000.00000000-1.00000000
θx180.00000
θy0.00000
θz45.00000
θx180.00000
θy0.00000
θz-45.00000
x1.00000
y1.00000
z4.00000

Expression of vectors and points in frames

Express a vector given in original_frame in a new frame.

[15]:
Vector([1,3,0]).express_in_frame(fa, original_frame=fb)
[15]:
x2.82843
y-1.41421
z0.00000

Express a point given in original_frame in a new frame.

[16]:
Point([5,3,20]).express_in_frame(fa, original_frame=fb)
[16]:
x7.07107
y1.41421
z-24.00000
[ ]: