10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-09 07:33:40 +01:00
QCaml/Utils/Coordinate.mli

93 lines
1.6 KiB
OCaml

(** Type for coordinates in 3D space.
All operations on points are done in atomic units. Therefore,
all coordinates are given in {!Bohr.t} and manipulated with this
module.
*)
type t = Bohr.t
type axis = X | Y | Z
val bohr_to_angstrom : Bohr.t -> Angstrom.t
(** Converts a point in Bohr to Angstrom. *)
val angstrom_to_bohr : Angstrom.t -> Bohr.t
(** Converts a point in Angstrom to Bohr. *)
val zero : Bohr.t
(** [zero = { Bohr.x = 0. ; y=0. ; z=0. }] *)
val get : axis -> Bohr.t -> float
(** Extracts the projection of the coordinate on an axis.
Example:
[Coordinate.(get Y) { Bohr.x=1. ; y=2. ; z=3. } -> 2.]
*)
(** {1 Vector operations} *)
val ( |. ) : float -> Bohr.t -> Bohr.t
(** Scale by a float.
Example:
[ 2. |. { Bohr.x=1. ; y=2. ; z=3. } -> { Bohr.x=2. ; y=4. ; z=6. } ]
*)
val ( |+ ) : Bohr.t -> Bohr.t -> Bohr.t
(** Add two vectors.
Example:
{[{ Bohr.x=1. ; y=2. ; z=3. } |+ { Bohr.x=2. ; y=3. ; z=1. } ->
{ Bohr.x=3. ; y=5. ; z=4. }]}
*)
val ( |- ) : Bohr.t -> Bohr.t -> Bohr.t
(** Subtract two vectors.
Example:
{[{ Bohr.x=1. ; y=2. ; z=3. } |- { Bohr.x=2. ; y=3. ; z=1. } ->
{ Bohr.x=-1. ; y=-1. ; z=2. }]}
*)
val neg : Bohr.t -> Bohr.t
(** Example:
{[Coordinate.neg { Bohr.x=1. ; y=2. ; z=-3. } ->
{ Bohr.x=-1. ; y=-2. ; z=3. }]}
*)
val dot : Bohr.t -> Bohr.t -> float
(** Dot product. *)
val norm : Bohr.t -> float
(** L{^2} norm of the vector. *)
(** {2 Printers} *)
val pp: Format.formatter -> Bohr.t -> unit
val pp_bohr: Format.formatter -> Bohr.t -> unit
val pp_angstrom : Format.formatter -> Bohr.t -> unit