Remove redundant access to vector model coords

This commit is contained in:
Hanno Braun 2022-02-20 12:38:33 +01:00
parent 05fb6b6190
commit 8256b5574a
3 changed files with 5 additions and 20 deletions

View File

@ -48,7 +48,7 @@ impl Circle {
/// error. /// error.
pub fn point_model_to_curve(&self, point: &Point<3>) -> Point<1> { pub fn point_model_to_curve(&self, point: &Point<3>) -> Point<1> {
let v = point - self.center; let v = point - self.center;
let atan = Scalar::atan2(v.y(), v.x()); let atan = Scalar::atan2(v.y, v.x);
let coord = if atan >= Scalar::ZERO { let coord = if atan >= Scalar::ZERO {
atan atan
} else { } else {

View File

@ -77,17 +77,17 @@ impl Point<2> {
impl Point<3> { impl Point<3> {
/// Access the point's x coordinate /// Access the point's x coordinate
pub fn x(&self) -> Scalar { pub fn x(&self) -> Scalar {
self.coords.x() self.coords.x
} }
/// Access the point's y coordinate /// Access the point's y coordinate
pub fn y(&self) -> Scalar { pub fn y(&self) -> Scalar {
self.coords.y() self.coords.y
} }
/// Access the point's z coordinate /// Access the point's z coordinate
pub fn z(&self) -> Scalar { pub fn z(&self) -> Scalar {
self.coords.z() self.coords.z
} }
} }

View File

@ -88,24 +88,9 @@ impl Vector<2> {
} }
impl Vector<3> { impl Vector<3> {
/// Access the vector's x coordinate
pub fn x(&self) -> Scalar {
self.0[0]
}
/// Access the vector's y coordinate
pub fn y(&self) -> Scalar {
self.0[1]
}
/// Access the vector's z coordinate
pub fn z(&self) -> Scalar {
self.0[2]
}
/// Construct a new vector from this vector's x and y components /// Construct a new vector from this vector's x and y components
pub fn xy(&self) -> Vector<2> { pub fn xy(&self) -> Vector<2> {
Vector::from([self.x(), self.y()]) Vector::from([self.x, self.y])
} }
} }