diff options
Diffstat (limited to 'src/math')
| -rw-r--r-- | src/math/rect.rs | 9 | ||||
| -rw-r--r-- | src/math/surface.rs | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/math/rect.rs b/src/math/rect.rs index adb608b..a8326bc 100644 --- a/src/math/rect.rs +++ b/src/math/rect.rs @@ -3,9 +3,9 @@ use super::{ExactSurface, LineSegment, Polygon, Vec2}; //use alga::general::{Additive, Identity}; use nalgebra::{RealField, Scalar}; -use num_traits::{NumCast, ToPrimitive}; +use num_traits::{NumCast, ToPrimitive, Zero}; use serde::{Deserialize, Serialize}; -use std::ops::{Add, AddAssign}; +use std::ops::{Add, AddAssign, Sub}; /// Represents a Rectangle with the value type T. #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] @@ -149,7 +149,10 @@ impl<T: Scalar + Copy> Rect<T> { } } -impl<T: RealField> ExactSurface<T> for Rect<T> { +impl<T: Scalar + Copy> ExactSurface<T> for Rect<T> +where + T: Add<Output = T> + PartialOrd + Sub<Output = T> + Zero, +{ fn contains_point(&self, point: &Vec2<T>) -> bool { point.x >= self.x && point.x <= self.x + self.w diff --git a/src/math/surface.rs b/src/math/surface.rs index 088ac47..21c3865 100644 --- a/src/math/surface.rs +++ b/src/math/surface.rs @@ -2,7 +2,7 @@ use super::{LineSegment, Polygon, Rect, Vec2}; use float_cmp::ApproxEq; -use nalgebra::RealField; +use nalgebra::{RealField, Scalar}; /// Trait that describes an area in the vector space on the field of T, with T unable to be /// used without rounding. @@ -28,7 +28,7 @@ where } /// The same as Surface, but the vector space will be assumed to be perfectly divideable or checkable. -pub trait ExactSurface<T: RealField> { +pub trait ExactSurface<T: Scalar + Copy> { /// Checks if a point lies on this surface. fn contains_point(&self, point: &Vec2<T>) -> bool; |
