# Module geometry

A module providing basic functions for vector and coordinate operations.

## Description

A module providing basic functions for vector and coordinate operations.

The include file "geometry.hrl" provides the definition of the records `#vector{}` and `#speric{}`, to represent coordinates and vectors (see below) and some macros, used to define colors, vectors and real measurement units. The following macros are available:
• `?VECTOR(X,Y,Z)`, defines a vector.
• `?RGB(R,G,B)`, defines an RGB color; costants are real numbers in the range [0,1].
• `?CM(X)`, defines a value in centimeters.
• `?MM(X)`, defines a value in millimeters.
• `?M(X)`, defines a value in meters.
• `?CM_S(X)`, defines a linear speed in cm/s.
• `?DEG_S(X)`, defines an angular speed in degree/s.

## Data Types

### spheric()

spheric() = #spheric{}

A record representing spheric coordinates. It has the fields:

• `rho`, the distance of the point from the origin;
• `theta`, the angle formed with the x axis along xy plane;
• `phi`, the angle formed with the z axis.

### vector()

vector() = #vector{}

A record representing a vector (or a point) in 3D space and has the fields `x`, `y` and `z`.

## Function Index

 add/2 Adds two vectors. angle/2 Determines the angle (in degrees) formed by two vectors. cartesian2spheric/1 Converts coordinates from cartesian to spheric. cross/2 Vector cross product. distance/2 Compute the distance between the targets of by two vectors. dot/2 Vector dot product. dot_v/2 Multiplies a scalar with a vector. norm/1 Computes the length of a vector. normalize_angle/1 Normalizes an angle (in degrees) in the range -180, 180. spheric2cartesian/1 Converts coordinates from spheric to cartesian. to_degrees/1 Coverts an angle from radiants to degree. to_radiants/1 Coverts an angle from degree to radiants.

## Function Details

### angle/2

angle(V1::vector(), V2::vector()) -> number()

Determines the angle (in degrees) formed by two vectors.

### cartesian2spheric/1

cartesian2spheric(V::vector()) -> spheric()

Converts coordinates from cartesian to spheric.

### cross/2

cross(V1::vector(), V2::vector()) -> number()

Vector cross product.

### distance/2

distance(V1::vector(), V2::vector()) -> number()

Compute the distance between the targets of by two vectors.

### dot/2

dot(V1::vector(), V2::vector()) -> number()

Vector dot product.

### dot_v/2

dot_v(A::number(), V::vector()) -> vector()

Multiplies a scalar with a vector.

### norm/1

norm(V::vector()) -> number()

Computes the length of a vector.

### normalize_angle/1

normalize_angle(Angle::number()) -> number()

Normalizes an angle (in degrees) in the range -180, 180.

### spheric2cartesian/1

spheric2cartesian(S::spheric()) -> vector()

Converts coordinates from spheric to cartesian.

### to_degrees/1

to_degrees(Angle::number()) -> number()

Coverts an angle from radiants to degree.