Routines for the manipulation of vectors.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | x_axis | = | 1 | |
integer, | public, | parameter | :: | y_axis | = | 2 | |
integer, | public, | parameter | :: | z_axis | = | 3 | |
real(kind=wp), | public, | parameter, dimension(3) | :: | x_unit | = | [one, zero, zero] |
x-axis unit vector |
real(kind=wp), | public, | parameter, dimension(3) | :: | y_unit | = | [zero, one, zero] |
y-axis unit vector |
real(kind=wp), | public, | parameter, dimension(3) | :: | z_unit | = | [zero, zero, one] |
z-axis unit vector |
Put the vector in the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x | ||
real(kind=wp), | intent(in), | dimension(:) | :: | vals | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Put the value in the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x | ||
real(kind=wp), | intent(in) | :: | val | |||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Put the vector in the vector and update the index (character version)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout), | dimension(:) | :: | x | ||
character(len=*), | intent(in), | dimension(:) | :: | vals | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Put the value in the vector and update the index (character version)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout), | dimension(:) | :: | x | ||
character(len=*), | intent(in) | :: | val | |||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Extract a vector from the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(out), | dimension(:) | :: | vals | ||
real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Extract the value from the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(out) | :: | val | |||
real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Cross product of two 3x1 vectors
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | r | ||
real(kind=wp), | intent(in), | dimension(3) | :: | v |
Unit vector
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | r |
Time derivative of a unit vector.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | u |
vector [ |
|
real(kind=wp), | intent(in), | dimension(3) | :: | udot |
derivative of vector [ |
derivative of unit vector [d(uhat)/dt
]
Unit vector of the cross product of two 3x1 vectors
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | v1 | ||
real(kind=wp), | intent(in), | dimension(3) | :: | v2 |
Computes the cross product matrix, where:
cross(a,b) == matmul(cross_matrix(a),b)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | r |
Computes the outer product of the two vectors.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | a | ||
real(kind=wp), | intent(in), | dimension(:) | :: | b |
Computes the box product (scalar triple product) of the three vectors.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | a | ||
real(kind=wp), | intent(in), | dimension(:) | :: | b | ||
real(kind=wp), | intent(in), | dimension(:) | :: | c |
The projection of one vector onto another vector.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | a |
the original vector |
|
real(kind=wp), | intent(in), | dimension(size(a)) | :: | b |
the vector to project on to |
the projection of a onto b
Convert spherical (r,alpha,beta) to Cartesian (x,y,z).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | r |
magnitude |
||
real(kind=wp), | intent(in) | :: | alpha |
right ascension [rad] |
||
real(kind=wp), | intent(in) | :: | beta |
declination [rad] |
[x,y,z] vector
The 3x3 rotation matrix for a rotation about the x, y, or z-axis.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | axis |
x_axis, y_axis, or z_axis |
||
real(kind=wp), | intent(in) | :: | angle |
angle in radians |
the rotation matrix
Time derivative of the 3x3 rotation matrix for a rotation about the x, y, or z-axis.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | axis |
x_axis, y_axis, or z_axis |
||
real(kind=wp), | intent(in) | :: | angle |
angle in radians |
||
real(kind=wp), | intent(in) | :: | angledot |
time derivative of angle in radians/sec |
the rotation matrix derivative
The angle between two vectors (in radians).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | v1 | ||
real(kind=wp), | intent(in), | dimension(3) | :: | v2 |
[rad]
Rotate a 3x1 vector in space, given an axis and angle of rotation.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | v |
vector to rotate |
|
real(kind=wp), | intent(in), | dimension(3) | :: | k |
rotation axis |
|
real(kind=wp), | intent(in) | :: | theta |
rotation angle [rad] |
||
real(kind=wp), | intent(out), | dimension(3) | :: | vrot |
result |
Project a vector onto a plane.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | a |
the original vector |
|
real(kind=wp), | intent(in), | dimension(3) | :: | b |
the plane to project on to (a normal vector) |
|
real(kind=wp), | intent(out), | dimension(3) | :: | c |
the projection of a onto the b plane |
Computes the rotation matrix that corresponds to a
rotation about the axis k
by an angle theta
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | k |
rotation axis |
|
real(kind=wp), | intent(in) | :: | theta |
rotation angle [rad] |
||
real(kind=wp), | intent(out), | dimension(3,3) | :: | rotmat |
rotation matrix |
Convert Cartesian (x,y,z) to spherical (r,alpha,beta).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | rvec |
[x,y,z] vector |
|
real(kind=wp), | intent(out) | :: | r |
magnitude |
||
real(kind=wp), | intent(out) | :: | alpha |
right ascension [rad] |
||
real(kind=wp), | intent(out) | :: | beta |
declination [rad] |
Put the vector in the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x | ||
real(kind=wp), | intent(in), | dimension(:) | :: | vals | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Put the value in the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x | ||
real(kind=wp), | intent(in) | :: | val | |||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Put the vector in the vector and update the index (character version)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout), | dimension(:) | :: | x | ||
character(len=*), | intent(in), | dimension(:) | :: | vals | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Put the value in the vector and update the index (character version)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout), | dimension(:) | :: | x | ||
character(len=*), | intent(in) | :: | val | |||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Extract a vector from the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(out), | dimension(:) | :: | vals | ||
real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |
Extract the value from the vector and update the index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(out) | :: | val | |||
real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
integer, | intent(inout) | :: | i |
should be initialized to 0 before the first call |