Skip to content

Commit

Permalink
Reviews - rect.rs and length.
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed May 26, 2017
1 parent 9ce0df9 commit 21a0117
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ where T: Copy + Clone + Zero + PartialOrd + PartialEq + Add<T, Output=T> + Sub<T
/// Returns the same rectangle, translated by a vector.
#[inline]
pub fn translate(&self, by: &TypedVector2D<T, U>) -> TypedRect<T, U> {
TypedRect::new(
TypedPoint2D::new(self.origin.x + by.x, self.origin.y + by.y),
self.size
)
Self::new(self.origin + *by, self.size)
}

/// Returns true if this rectangle contains the point. Points are considered
Expand Down
12 changes: 6 additions & 6 deletions src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ where T: Copy + Mul<T, Output=T> + Add<T, Output=T> + Sub<T, Output=T> {
}

#[inline]
pub fn square_norm(&self) -> T {
pub fn square_length(&self) -> T {
self.x * self.x + self.y * self.y
}

#[inline]
pub fn norm(&self) -> T where T: Float + ApproxEq<T> {
self.square_norm().sqrt()
pub fn length(&self) -> T where T: Float + ApproxEq<T> {
self.square_length().sqrt()
}
}

Expand Down Expand Up @@ -473,13 +473,13 @@ impl<T: Mul<T, Output=T> +
}

#[inline]
pub fn square_norm(&self) -> T {
pub fn square_length(&self) -> T {
self.x * self.x + self.y * self.y + self.z * self.z
}

#[inline]
pub fn norm(&self) -> T where T: Float + ApproxEq<T> {
self.square_norm().sqrt()
pub fn length(&self) -> T where T: Float + ApproxEq<T> {
self.square_length().sqrt()
}
}

Expand Down

0 comments on commit 21a0117

Please sign in to comment.