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 |
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
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 |
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
[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]:
x | 1.00000 |
y | 1.00000 |
z | 4.00000 |
[9]:
fc.rotation
[9]:
0.70710678 | 0.70710678 | 0.00000000 |
0.70710678 | -0.70710678 | 0.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 |
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
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 |
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
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 |
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
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]:
x | 2.82843 |
y | -1.41421 |
z | 0.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]:
x | 7.07107 |
y | 1.41421 |
z | -24.00000 |
[ ]: