vector_module Module

Routines for the manipulation of vectors.


Uses

  • module~~vector_module~~UsesGraph module~vector_module vector_module module~kind_module kind_module module~vector_module->module~kind_module module~numbers_module numbers_module module~vector_module->module~numbers_module iso_fortran_env iso_fortran_env module~kind_module->iso_fortran_env module~numbers_module->module~kind_module

Used by

  • module~~vector_module~~UsedByGraph module~vector_module vector_module module~bplane_module bplane_module module~bplane_module->module~vector_module module~fortran_astrodynamics_toolkit fortran_astrodynamics_toolkit module~fortran_astrodynamics_toolkit->module~vector_module module~fortran_astrodynamics_toolkit->module~bplane_module module~geometry_module geometry_module module~fortran_astrodynamics_toolkit->module~geometry_module module~lambert_module lambert_module module~fortran_astrodynamics_toolkit->module~lambert_module module~modified_equinoctial_module modified_equinoctial_module module~fortran_astrodynamics_toolkit->module~modified_equinoctial_module module~orbital_mechanics_module orbital_mechanics_module module~fortran_astrodynamics_toolkit->module~orbital_mechanics_module module~transformation_module transformation_module module~fortran_astrodynamics_toolkit->module~transformation_module module~geometry_module->module~vector_module module~lambert_module->module~vector_module module~modified_equinoctial_module->module~vector_module module~orbital_mechanics_module->module~vector_module module~transformation_module->module~vector_module proc~from_ijk_to_lvlh_mat relative_motion_module::from_ijk_to_lvlh_mat proc~from_ijk_to_lvlh_mat->module~vector_module proc~from_ijk_to_rsw_mat relative_motion_module::from_ijk_to_rsw_mat proc~from_ijk_to_rsw_mat->module~vector_module proc~from_lvlh_to_ijk_mat relative_motion_module::from_lvlh_to_ijk_mat proc~from_lvlh_to_ijk_mat->module~vector_module proc~from_rsw_to_ijk_mat relative_motion_module::from_rsw_to_ijk_mat proc~from_rsw_to_ijk_mat->module~vector_module proc~geopotential_module_test geopotential_module::geopotential_module_test proc~geopotential_module_test->module~vector_module proc~iau_rotation_matrix iau_orientation_module::iau_rotation_matrix proc~iau_rotation_matrix->module~vector_module proc~rk_test_variable_step rk_module_variable_step::rk_test_variable_step proc~rk_test_variable_step->module~orbital_mechanics_module

Variables

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


Interfaces

public interface fill_vector

  • private subroutine fill_vector_with_vector(x, vals, i)

    Put the vector in the vector and update the index

    Arguments

    Type IntentOptional 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

  • private subroutine fill_vector_with_scalar(x, val, i)

    Put the value in the vector and update the index

    Arguments

    Type IntentOptional 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

  • private subroutine fill_char_vector_with_vector(x, vals, i)

    Put the vector in the vector and update the index (character version)

    Arguments

    Type IntentOptional 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

  • private subroutine fill_char_vector_with_scalar(x, val, i)

    Put the value in the vector and update the index (character version)

    Arguments

    Type IntentOptional 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

public interface extract_vector

  • private subroutine extract_vector_from_vector(vals, x, i)

    Extract a vector from the vector and update the index

    Arguments

    Type IntentOptional 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

  • private subroutine extract_scalar_from_vector(val, x, i)

    Extract the value from the vector and update the index

    Arguments

    Type IntentOptional 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


Functions

public pure function cross(r, v) result(rxv)

Author
Jacob Williams

Cross product of two 3x1 vectors

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(3) :: r
real(kind=wp), intent(in), dimension(3) :: v

Return Value real(kind=wp), dimension(3)

public pure function unit(r) result(u)

Author
Jacob Williams

Unit vector

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:) :: r

Return Value real(kind=wp), dimension(size(r))

public pure function uhat_dot(u, udot) result(uhatd)

Author
Jacob Williams

Time derivative of a unit vector.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(3) :: u

vector [u]

real(kind=wp), intent(in), dimension(3) :: udot

derivative of vector [du/dt]

Return Value real(kind=wp), dimension(3)

derivative of unit vector [d(uhat)/dt]

public pure function ucross(v1, v2) result(u)

Author
Jacob Williams

Unit vector of the cross product of two 3x1 vectors

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(3) :: v1
real(kind=wp), intent(in), dimension(3) :: v2

Return Value real(kind=wp), dimension(3)

public pure function cross_matrix(r) result(rcross)

Author
Jacob Williams
Date
7/20/2014

Computes the cross product matrix, where: cross(a,b) == matmul(cross_matrix(a),b)

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(3) :: r

Return Value real(kind=wp), dimension(3,3)

public pure function outer_product(a, b) result(c)

Author
Jacob Williams
Date
7/21/2014

Computes the outer product of the two vectors.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:) :: a
real(kind=wp), intent(in), dimension(:) :: b

Return Value real(kind=wp), dimension(size(a),size(b))

public pure function box_product(a, b, c) result(d)

Author
Jacob Williams
Date
7/21/2014

Computes the box product (scalar triple product) of the three vectors.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:) :: a
real(kind=wp), intent(in), dimension(:) :: b
real(kind=wp), intent(in), dimension(:) :: c

Return Value real(kind=wp)

public pure function vector_projection(a, b) result(c)

Author
Jacob Williams
Date
7/21/2014

The projection of one vector onto another vector.

Read more…

Arguments

Type IntentOptional 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

Return Value real(kind=wp), dimension(size(a))

the projection of a onto b

public pure function spherical_to_cartesian(r, alpha, beta) result(rvec)

Author
Jacob Williams
Date
9/24/2014

Convert spherical (r,alpha,beta) to Cartesian (x,y,z).

Arguments

Type IntentOptional 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]

Return Value real(kind=wp), dimension(3)

[x,y,z] vector

public pure function rotation_matrix(axis, angle) result(rotmat)

Author
Jacob Williams
Date
2/3/2015

The 3x3 rotation matrix for a rotation about the x, y, or z-axis.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: axis

x_axis, y_axis, or z_axis

real(kind=wp), intent(in) :: angle

angle in radians

Return Value real(kind=wp), dimension(3,3)

the rotation matrix

public pure function rotation_matrix_dot(axis, angle, angledot) result(rotmatdot)

Author
Jacob Williams
Date
3/19/2016

Time derivative of the 3x3 rotation matrix for a rotation about the x, y, or z-axis.

Arguments

Type IntentOptional 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

Return Value real(kind=wp), dimension(3,3)

the rotation matrix derivative

public pure function angle_between_vectors(v1, v2) result(ang)

Author
Jacob Williams
Date
3/13/2015

The angle between two vectors (in radians).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(3) :: v1
real(kind=wp), intent(in), dimension(3) :: v2

Return Value real(kind=wp)

[rad]


Subroutines

public pure subroutine axis_angle_rotation(v, k, theta, vrot)

Author
Jacob Williams
Date
7/20/2014

Rotate a 3x1 vector in space, given an axis and angle of rotation.

Read more…

Arguments

Type IntentOptional 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

public pure subroutine vector_projection_on_plane(a, b, c)

Project a vector onto a plane.

Read more…

Arguments

Type IntentOptional 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

public pure subroutine axis_angle_rotation_to_rotation_matrix(k, theta, rotmat)

Author
Jacob Williams
Date
7/20/2014

Computes the rotation matrix that corresponds to a rotation about the axis k by an angle theta.

Arguments

Type IntentOptional 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

public pure subroutine cartesian_to_spherical(rvec, r, alpha, beta)

Author
Jacob Williams
Date
3/6/2016

Convert Cartesian (x,y,z) to spherical (r,alpha,beta).

Arguments

Type IntentOptional 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]

private subroutine fill_vector_with_vector(x, vals, i)

Put the vector in the vector and update the index

Arguments

Type IntentOptional 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

private subroutine fill_vector_with_scalar(x, val, i)

Put the value in the vector and update the index

Arguments

Type IntentOptional 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

private subroutine fill_char_vector_with_vector(x, vals, i)

Put the vector in the vector and update the index (character version)

Arguments

Type IntentOptional 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

private subroutine fill_char_vector_with_scalar(x, val, i)

Put the value in the vector and update the index (character version)

Arguments

Type IntentOptional 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

private subroutine extract_vector_from_vector(vals, x, i)

Extract a vector from the vector and update the index

Arguments

Type IntentOptional 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

private subroutine extract_scalar_from_vector(val, x, i)

Extract the value from the vector and update the index

Arguments

Type IntentOptional 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

public subroutine vector_test()

Author
Jacob Williams
Date
7/20/2014

Unit test routine for the vector_module.

Arguments

None