|
1 | 1 | # License for this file: MIT (expat) |
2 | | -# Copyright 2017-2018, DLR Institute of System Dynamics and Control |
| 2 | +# Copyright 2017-2022, DLR Institute of System Dynamics and Control |
3 | 3 |
|
4 | 4 | """ |
5 | 5 | module Modia3D.Frames |
6 | 6 |
|
7 | 7 | This module contains functions for **frames** that is coordinate systems in 3D. |
8 | 8 | The orientation of a frame is described either with a 3x3 **rotation matrix** |
9 | | -or with a **quaternion vector** and its origin is described with a **SVector{3,Float64}**: |
10 | | -
|
11 | | -- Rotation matrix `SMatrix{3,3,Float64,9}`: |
12 | | - Type of a Rotation matrix to rotate from a frame 1 into a frame 2. |
13 | | -
|
14 | | -- `quaternion = SVector{4,Float64}`: |
15 | | - Type of a quaternion vector to rotate from a frame 1 into a frame 2. |
16 | | -
|
17 | | -
|
18 | | -The following constants are defined |
19 | | -
|
20 | | -- `Modia3D.NullRotation(F)`: |
21 | | - rotation matrix with no rotation from a frame 1 into a frame 2. |
22 | | -
|
23 | | -- `Modia3D.NullQuaternion(F)`: |
24 | | - Quaternion vector with no rotation from a frame 1 into a frame 2. |
25 | | -
|
26 | | -- `Modia3D.ZeroVector3D(F)`: |
27 | | - SVector{3,Float64} with only zero elements. |
28 | | -
|
29 | | -If an angle is given as an argument to one of the functions below, it might be a |
30 | | -number (interpreted as having unit `rad`) or a number with a unit |
31 | | -(for example: `using Unitful; angle = 90u"°"`). |
32 | | -
|
33 | | -
|
34 | | -# Constructors for a RotationMatrix R |
35 | | -
|
36 | | -The following functions return a rotation matrix `R` |
37 | | -to rotate a frame 1 into a frame 2. |
38 | | -
|
39 | | -| Function | Description | |
40 | | -|:-------------------------------------------------|:---------------------------------------------------| |
41 | | -| [`Modia3D.rot1`](@ref)(angle) | Rotate around `angle` along x-axis | |
42 | | -| [`Modia3D.rot2`](@ref)(angle) | Rotate around `angle` along y-axis | |
43 | | -| [`Modia3D.rot3`](@ref)(angle) | Rotate around `angle` along z-axis | |
44 | | -| [`Modia3D.rot123`](@ref)(angle1, angle2, angle3) | Rotate around angles along x,y,z-axes | |
45 | | -| [`Modia3D.rotAxis`](@ref)(axis,angle) | Rotate around `angle` along `axis` (= 1,2,3) | |
46 | | -| [`Modia3D.rotAxis`](@ref)(axis,positive,angle) | Rotate around `angle` if `positive`, else `-angle` | |
47 | | -| [`Modia3D.rot_e`](@ref)(e, angle) | Rotate around `angle` along unit vector `e` | |
48 | | -| [`Modia3D.rot_nxy`](@ref)(nx, ny) | `nx`/`ny` are in x/y-direction of frame 2 | |
49 | | -| [`Modia3D.from_q`](@ref)(q) | Return `R` from quaternion `q` | |
50 | | -
|
51 | | -
|
52 | | -# Constructors for a quaternion q |
53 | | -
|
54 | | -The following functions return a quaternion SVector{4,F} `q` |
55 | | -to rotate a frame 1 into a frame 2. |
56 | | -Since `q` and `-q` define the same rotation the constructor functions have |
57 | | -a keyword argument `q_guess::SVector{4,F} = NullQuaternion(F)`. |
58 | | -From the two possible solutions `q` the one is returned that is closer to `q_guess`. |
59 | | -
|
60 | | -| Function | Description | |
61 | | -|:--------------------------------------------------|:-------------------------------------------| |
62 | | -| [`Modia3D.qrot1`](@ref)(angle) | Rotate around `angle` along x-axis | |
63 | | -| [`Modia3D.qrot2`](@ref)(angle) | Rotate around `angle` along y-axis | |
64 | | -| [`Modia3D.qrot3`](@ref)(angle) | Rotate around `angle` along z-axis | |
65 | | -| [`Modia3D.qrot123`](@ref)(angle1, angle2, angle3) | Rotate around angles along x,y,z-axes | |
66 | | -| [`Modia3D.qrot_e`](@ref)(e, angle) | Rotate around `angle` along unit vector `e`| |
67 | | -| [`Modia3D.qrot_nxy`](@ref)(nx, ny) | `nx`/`ny` are in x/y-direction of frame 2 | |
68 | | -| [`Modia3D.from_R`](@ref)(R) | Return `q` from SMatrix{3,3,F,9} `R` | |
69 | | -
|
70 | | -
|
71 | | -# Operations on Frames |
72 | | -
|
73 | | -The following functions provide operations on frames. The orientation of a frame is |
74 | | -defined with argument `Rq` meaning it can be either a |
75 | | -rotation matrix ` R` or a |
76 | | -quaternion ` q` (to rotate a frame 1 into a frame 2). |
77 | | -
|
78 | | -| Function | Description | |
79 | | -|:-----------------------------------------------|:----------------------------------------------| |
80 | | -| [`Modia3D.resolve1`](@ref)(Rq, v2) | Transform vector `v` from frame 2 to frame 1 | |
81 | | -| [`Modia3D.resolve2`](@ref)(Rq, v1) | Transform vector `v` from frame 1 to frame 2 | |
82 | | -| [`Modia3D.absoluteRotation`](@ref)(Rq01, Rq12) | Return rotation 0->2 from rot. 0->1 and 1->2 | |
83 | | -| [`Modia3D.relativeRotation`](@ref)(Rq01, Rq02) | Return rotation 1->2 from rot. 0->1 and 0->2 | |
84 | | -| [`Modia3D.inverseRotation`](@ref)(Rq01) | Return rotation 1->0 from rot, 0->1 | |
85 | | -| [`Modia3D.planarRotationAngle`](@ref)(e,v1,v2) | Return angle of planar rotation along `e` | |
86 | | -| [`Modia3D.eAxis`](@ref)(axis) | Return unit vector `e` in direction of `axis` | |
87 | | -| [`Modia3D.skew`](@ref)(v) | Return skew-symmetric matrix of vector v | |
88 | | -
|
89 | | -
|
90 | | -# Interpolation of Frames |
91 | | -
|
92 | | -Given a set of frames by a vector `r` of position vectors to their origins and |
93 | | -and an optional vector `q` of Quaternions of their absolute orientations, then |
94 | | -the following functions interpolate linearly in these frames: |
95 | | -
|
96 | | -| Function | Description | |
97 | | -|:------------------------------------------------|:-----------------------------------------------| |
98 | | -| [`Modia3D.Path`](@ref)(r,q) | Return path defined by a vector of frames | |
99 | | -| [`Modia3D.t_pathEnd`](@ref)(path) | Return path parameter `t_end` of last frame | |
100 | | -| [`Modia3D.interpolate`](@ref)(path,t) | Return `(rt,qt)` of Path at path parameter `t` | |
101 | | -| [`Modia3D.interpolate_r`](@ref)(path,t) | Return `rt` of Path at path parameter `t` | |
102 | | -
|
103 | | -
|
104 | | -# Examples |
105 | | -
|
106 | | -```julia |
107 | | -using Modia3D |
108 | | -using Unitful |
109 | | -
|
110 | | -# R1,R2,R3 are the same RotationMatrices |
111 | | -R1 = Modia3D.rot1(pi/2) |
112 | | -R2 = Modia3D.rot1(90u"°") |
113 | | -R3 = Modia3D.rot_e([1,0,0], pi/2) |
114 | | -``` |
| 9 | +or with a **quaternion vector** and its origin is described with a **SVector{3,Float64}**. |
| 10 | +For details see Modia3D/docs/Functions.md. |
115 | 11 |
|
116 | 12 | # Main developer |
117 | 13 |
|
|
0 commit comments