Add Ray constructor that ensures direction vector is normalized
This commit is contained in:
parent
ff046808da
commit
9ebfae5898
|
|
@ -6,6 +6,15 @@ struct Ray<T: RealField> {
|
||||||
direction: Vector3<T>,
|
direction: Vector3<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: RealField> Ray<T> {
|
||||||
|
fn new(origin: Vector3<T>, direction: Vector3<T>) -> Ray<T> {
|
||||||
|
Ray {
|
||||||
|
origin,
|
||||||
|
direction: direction.normalize(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: RealField> Ray<T> {
|
impl<T: RealField> Ray<T> {
|
||||||
fn point_at(&self, t: T) -> Vector3<T> {
|
fn point_at(&self, t: T) -> Vector3<T> {
|
||||||
return self.origin + self.direction * t;
|
return self.origin + self.direction * t;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue