Geometric Operations

Face Properties

AsteroidShapeModels.face_centerFunction
face_center(vs::StaticVector{3, <:StaticVector{3}}) -> StaticVector{3}
face_center(v1::StaticVector{3}, v2::StaticVector{3}, v3::StaticVector{3}) -> StaticVector{3}

Calculate the center (centroid) of a triangular face.

Arguments

  • vs: A static vector containing three vertices of the triangle
  • v1, v2, v3: Three vertices of the triangle

Returns

  • StaticVector{3}: The center point of the triangle, computed as the arithmetic mean of the three vertices

Examples

v1 = SA[1.0, 0.0, 0.0]
v2 = SA[0.0, 1.0, 0.0]
v3 = SA[0.0, 0.0, 1.0]
center = face_center(v1, v2, v3)  # Returns SA[1/3, 1/3, 1/3]
source
AsteroidShapeModels.face_normalFunction
face_normal(vs::StaticVector{3, <:StaticVector{3}}) -> StaticVector{3}
face_normal(v1::StaticVector{3}, v2::StaticVector{3}, v3::StaticVector{3}) -> StaticVector{3}

Calculate the unit normal vector of a triangular face.

Arguments

  • vs: A static vector containing three vertices of the triangle
  • v1, v2, v3: Three vertices of the triangle in counter-clockwise order

Returns

  • StaticVector{3}: The unit normal vector pointing outward from the face (following right-hand rule)

Notes

The normal direction follows the right-hand rule based on the vertex ordering. For a counter-clockwise vertex ordering when viewed from outside, the normal points outward.

Examples

v1 = SA[1.0, 0.0, 0.0]
v2 = SA[0.0, 1.0, 0.0]
v3 = SA[0.0, 0.0, 0.0]
normal = face_normal(v1, v2, v3)  # Returns SA[0.0, 0.0, 1.0]
source
AsteroidShapeModels.face_areaFunction
face_area(vs::StaticVector{3, <:StaticVector{3}}) -> Real
face_area(v1::StaticVector{3}, v2::StaticVector{3}, v3::StaticVector{3}) -> Real

Calculate the area of a triangular face.

Arguments

  • vs: A static vector containing three vertices of the triangle
  • v1, v2, v3: Three vertices of the triangle

Returns

  • Real: The area of the triangle

Notes

The area is computed using the cross product formula: area = ||(v2 - v1) × (v3 - v2)|| / 2

Examples

# Unit right triangle
v1 = SA[0.0, 0.0, 0.0]
v2 = SA[1.0, 0.0, 0.0]
v3 = SA[0.0, 1.0, 0.0]
area = face_area(v1, v2, v3)  # Returns 0.5
source

Shape Properties

AsteroidShapeModels.polyhedron_volumeFunction
polyhedron_volume(nodes, faces) -> Float64
polyhedron_volume(shape::ShapeModel) -> Float64

Calculate the volume of a polyhedron using the divergence theorem.

Arguments

  • nodes: Array of vertex positions
  • faces: Array of triangular face definitions (vertex indices)
  • shape::ShapeModel: A shape model containing nodes and faces

Returns

  • Float64: Volume of the polyhedron

Notes

The volume is computed using the formula: V = (1/6) * Σ (A × B) · C where A, B, C are the vertices of each triangular face. The shape must be a closed polyhedron with consistently oriented faces.

Examples

# Unit cube
nodes = [SA[0,0,0], SA[1,0,0], SA[1,1,0], SA[0,1,0],
         SA[0,0,1], SA[1,0,1], SA[1,1,1], SA[0,1,1]]
faces = [SA[1,2,3], SA[1,3,4], ...]  # Define all 12 triangular faces
vol = polyhedron_volume(nodes, faces)  # Returns 1.0
source
AsteroidShapeModels.equivalent_radiusFunction
equivalent_radius(VOLUME::Real) -> Float64
equivalent_radius(shape::ShapeModel) -> Float64

Calculate the radius of a sphere with the same volume as the given volume or shape.

Arguments

  • VOLUME::Real: Volume of the object
  • shape::ShapeModel: A shape model to calculate volume from

Returns

  • Float64: Radius of the equivalent sphere

Notes

The equivalent radius is calculated as: r = (3V/4π)^(1/3)

Examples

# Sphere with radius 2
volume = 4π/3 * 2^3
r_eq = equivalent_radius(volume)  # Returns 2.0

# From shape model
shape = load_shape_obj("asteroid.obj")
r_eq = equivalent_radius(shape)
source
AsteroidShapeModels.maximum_radiusFunction
maximum_radius(nodes) -> Float64
maximum_radius(shape::ShapeModel) -> Float64

Calculate the maximum distance from the origin to any vertex.

Arguments

  • nodes: Array of vertex positions
  • shape::ShapeModel: A shape model containing nodes

Returns

  • Float64: Maximum distance from origin to any vertex

Notes

This represents the radius of the smallest sphere centered at the origin that contains all vertices of the shape.

Examples

nodes = [SA[1,0,0], SA[0,2,0], SA[0,0,3]]
r_max = maximum_radius(nodes)  # Returns 3.0
source
AsteroidShapeModels.minimum_radiusFunction
minimum_radius(nodes) -> Float64
minimum_radius(shape::ShapeModel) -> Float64

Calculate the minimum distance from the origin to any vertex.

Arguments

  • nodes: Array of vertex positions
  • shape::ShapeModel: A shape model containing nodes

Returns

  • Float64: Minimum distance from origin to any vertex

Notes

This represents the radius of the largest sphere centered at the origin that fits entirely inside the convex hull of the vertices.

Examples

nodes = [SA[1,0,0], SA[0,2,0], SA[0,0,3]]
r_min = minimum_radius(nodes)  # Returns 1.0
source

Angle Calculations

AsteroidShapeModels.angle_radFunction
angle_rad(v1, v2) -> Float64

Calculate the angle between two vectors in radians.

Arguments

  • v1 : First vector
  • v2 : Second vector

Returns

  • Angle between vectors in radians [0, π]
source
angle_rad(v1::AbstractVector{<:AbstractVector}, v2::AbstractVector{<:AbstractVector}) -> Vector{Float64}

Calculate angles between corresponding pairs of vectors in two arrays (broadcast version).

Arguments

  • v1: Array of first vectors
  • v2: Array of second vectors (must have same length as v1)

Returns

  • Array of angles in radians between corresponding vector pairs

Examples

v1s = [SA[1,0,0], SA[0,1,0]]
v2s = [SA[0,1,0], SA[1,0,0]]
angles = angle_rad(v1s, v2s)  # Returns [π/2, π/2]
source
AsteroidShapeModels.angle_degFunction
angle_deg(v1, v2) -> Float64

Calculate the angle between two vectors in degrees.

Arguments

  • v1 : First vector
  • v2 : Second vector

Returns

  • Angle between vectors in degrees [0, 180]
source
angle_deg(v1::AbstractVector{<:AbstractVector}, v2::AbstractVector{<:AbstractVector}) -> Vector{Float64}

Calculate angles between corresponding pairs of vectors in two arrays (broadcast version).

Arguments

  • v1: Array of first vectors
  • v2: Array of second vectors (must have same length as v1)

Returns

  • Array of angles in degrees between corresponding vector pairs

Examples

v1s = [SA[1,0,0], SA[0,1,0]]
v2s = [SA[0,1,0], SA[1,0,0]]
angles = angle_deg(v1s, v2s)  # Returns [90.0, 90.0]
source
AsteroidShapeModels.solar_phase_angleFunction
solar_phase_angle(sun, target, observer) -> Float64

Calculate a sun-target-observer angle (phase angle).

Arguments

  • sun : Sun position vector
  • target : Target position vector
  • observer : Observer position vector

Returns

  • ∠STO : Sun-target-observer angle (phase angle) [rad]
source
AsteroidShapeModels.solar_elongation_angleFunction
solar_elongation_angle(sun, observer, target) -> Float64

Calculate a sun-observer-target angle (solar elongation angle).

Arguments

  • sun : Sun position vector
  • observer : Observer position vector
  • target : Target position vector

Returns

  • ∠SOT : Sun-observer-target angle (solar elongation angle) [rad]
source