Trait geodesy::CoordinateTuple
source · pub trait CoordinateTuple {
Show 30 methods
// Required methods
fn nth_unchecked(&self, n: usize) -> f64;
fn set_nth_unchecked(&mut self, n: usize, value: f64);
fn dim(&self) -> usize;
// Provided methods
fn nth(&self, n: usize) -> f64 { ... }
fn x(&self) -> f64 { ... }
fn y(&self) -> f64 { ... }
fn z(&self) -> f64 { ... }
fn t(&self) -> f64 { ... }
fn xy(&self) -> (f64, f64) { ... }
fn xyz(&self) -> (f64, f64, f64) { ... }
fn xyzt(&self) -> (f64, f64, f64, f64) { ... }
fn xy_to_degrees(&self) -> (f64, f64) { ... }
fn xyz_to_degrees(&self) -> (f64, f64, f64) { ... }
fn xyzt_to_degrees(&self) -> (f64, f64, f64, f64) { ... }
fn xy_to_arcsec(&self) -> (f64, f64) { ... }
fn xyz_to_arcsec(&self) -> (f64, f64, f64) { ... }
fn xyzt_to_arcsec(&self) -> (f64, f64, f64, f64) { ... }
fn xy_to_radians(&self) -> (f64, f64) { ... }
fn xyz_to_radians(&self) -> (f64, f64, f64) { ... }
fn xyzt_to_radians(&self) -> (f64, f64, f64, f64) { ... }
fn fill(&mut self, value: f64) { ... }
fn set_nth(&mut self, n: usize, value: f64) { ... }
fn set_xy(&mut self, x: f64, y: f64) { ... }
fn set_xyz(&mut self, x: f64, y: f64, z: f64) { ... }
fn set_xyzt(&mut self, x: f64, y: f64, z: f64, t: f64) { ... }
fn update(&mut self, value: &[f64]) { ... }
fn hypot2(&self, other: &Self) -> f64
where Self: Sized { ... }
fn hypot3(&self, other: &Self) -> f64
where Self: Sized { ... }
fn scale(&self, factor: f64) -> Self
where Self: Sized + Copy { ... }
fn dot(&self, other: Self) -> f64
where Self: Sized { ... }
}
Expand description
CoordinateTuple is the ISO-19111 atomic spatial/spatiotemporal referencing element. So loosely speaking, a CoordinateSet is a collection of CoordinateTuples.
Note that (despite the formal name) the underlying data structure need not be a tuple: It can be any item, for which it makes sense to implement the CoordinateTuple trait.
The CoordinateTuple trait provides a number of convenience accessors for accessing single coordinate elements or tuples of subsets. These accessors are pragmatically named (x, y, xy, etc.). While these names may be geodetically naïve, they are suggestive, practical, and aligns well with the internal coordinate order convention of most Geodesy operators.
All accessors have default implementations, except the 3 methods
nth_unchecked()
,
set_nth_unchecked()
and
dim()
,
which must be provided by the implementer.
When accessing dimensions outside of the domain of the CoordinateTuple, NaN will be returned.
Required Methods§
sourcefn nth_unchecked(&self, n: usize) -> f64
fn nth_unchecked(&self, n: usize) -> f64
Access the n’th (0-based) element of the CoordinateTuple.
May panic if n >= DIMENSION.
See also nth()
.
sourcefn set_nth_unchecked(&mut self, n: usize, value: f64)
fn set_nth_unchecked(&mut self, n: usize, value: f64)
Provided Methods§
sourcefn nth(&self, n: usize) -> f64
fn nth(&self, n: usize) -> f64
Access the n’th (0-based) element of the CoordinateTuple.
Returns NaN if n >= DIMENSION
.
See also nth()
.
sourcefn xyz(&self) -> (f64, f64, f64)
fn xyz(&self) -> (f64, f64, f64)
A tuple containing the first three components of the CoordinateTuple.
sourcefn xyzt(&self) -> (f64, f64, f64, f64)
fn xyzt(&self) -> (f64, f64, f64, f64)
A tuple containing the first four components of the CoordinateTuple.
sourcefn xy_to_degrees(&self) -> (f64, f64)
fn xy_to_degrees(&self) -> (f64, f64)
A tuple containing the first two components of the CoordinateTuple converted from radians to degrees
sourcefn xyz_to_degrees(&self) -> (f64, f64, f64)
fn xyz_to_degrees(&self) -> (f64, f64, f64)
A tuple containing the first three components of the CoordinateTuple, with the first two converted from radians to degrees.
sourcefn xyzt_to_degrees(&self) -> (f64, f64, f64, f64)
fn xyzt_to_degrees(&self) -> (f64, f64, f64, f64)
A tuple containing the first four components of the CoordinateTuple, with the first two converted from radians to degrees.
sourcefn xy_to_arcsec(&self) -> (f64, f64)
fn xy_to_arcsec(&self) -> (f64, f64)
A tuple containing the first two components of the CoordinateTuple, converted from radians to seconds-of-arc
sourcefn xyz_to_arcsec(&self) -> (f64, f64, f64)
fn xyz_to_arcsec(&self) -> (f64, f64, f64)
A tuple containing the first three components of the CoordinateTuple, with the first two converted to seconds-of-arc
sourcefn xyzt_to_arcsec(&self) -> (f64, f64, f64, f64)
fn xyzt_to_arcsec(&self) -> (f64, f64, f64, f64)
A tuple containing the first four components of the CoordinateTuple, with the first two converted to seconds-of-arc
sourcefn xy_to_radians(&self) -> (f64, f64)
fn xy_to_radians(&self) -> (f64, f64)
A tuple containing the first two components of the CoordinateTuple, converted from degrees to radians
sourcefn xyz_to_radians(&self) -> (f64, f64, f64)
fn xyz_to_radians(&self) -> (f64, f64, f64)
A tuple containing the first three components of the CoordinateTuple, with the first two converted from degrees to radians
sourcefn xyzt_to_radians(&self) -> (f64, f64, f64, f64)
fn xyzt_to_radians(&self) -> (f64, f64, f64, f64)
A tuple containing the first four components of the CoordinateTuple, with the first two converted from degrees to radians
sourcefn set_nth(&mut self, n: usize, value: f64)
fn set_nth(&mut self, n: usize, value: f64)
Replace the n’th (0-based) element of the CoordinateTuple
with value
.
If n >=
dim()
fill the coordinate with f64::NAN
.
See also set_nth_unchecked()
.
sourcefn set_xy(&mut self, x: f64, y: f64)
fn set_xy(&mut self, x: f64, y: f64)
Replace the two first elements of the CoordinateTuple
with x
and y
.
If the dimension is less than 2, fill the coordinate with f64::NAN
.
See also set_nth_unchecked()
.
sourcefn set_xyz(&mut self, x: f64, y: f64, z: f64)
fn set_xyz(&mut self, x: f64, y: f64, z: f64)
Replace the three first elements of the CoordinateTuple
with x
, y
and z
.
If the dimension is less than 3, fill the coordinate with f64::NAN
.
sourcefn set_xyzt(&mut self, x: f64, y: f64, z: f64, t: f64)
fn set_xyzt(&mut self, x: f64, y: f64, z: f64, t: f64)
Replace the four first elements of the CoordinateTuple
with x
, y
z
and t
.
If the dimension is less than 4, fill the coordinate with f64::NAN
.
sourcefn update(&mut self, value: &[f64])
fn update(&mut self, value: &[f64])
Replace the N
first (up to dim()
) elements of self
with the
elements of value
sourcefn hypot2(&self, other: &Self) -> f64where
Self: Sized,
fn hypot2(&self, other: &Self) -> f64where
Self: Sized,
Euclidean distance between two points in the 2D plane.
Primarily used to compute the distance between two projected points in their projected plane. Typically, this distance will differ from the actual distance in the real world.
§See also:
§Examples
use geodesy::prelude::*;
let t = 1000 as f64;
let p0 = Coor2D::origin();
let p1 = Coor2D::raw(t, t);
assert_eq!(p0.hypot2(&p1), t.hypot(t));
sourcefn hypot3(&self, other: &Self) -> f64where
Self: Sized,
fn hypot3(&self, other: &Self) -> f64where
Self: Sized,
Euclidean distance between two points in the 3D space.
Primarily used to compute the distance between two points in the 3D cartesian space. The typical case is GNSS-observations, in which case, the distance computed will reflect the actual distance in the real world.
The distance is computed in the subspace spanned by the first,
second and third coordinate of the Coor3D
s
§See also:
§Examples
use geodesy::prelude::*;
let t = 1000 as f64;
let p0 = Coor3D::origin();
let p1 = Coor3D::raw(t, t, t);
assert_eq!(p0.hypot3(&p1), t.hypot(t).hypot(t));