nalgebra/geometry/
scale_ops.rs

1use std::ops::{Mul, MulAssign};
2
3use simba::scalar::ClosedMulAssign;
4
5use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
6use crate::base::dimension::U1;
7use crate::base::{Const, SVector, Scalar};
8
9use crate::geometry::{Point, Scale};
10
11// Scale × Scale
12add_sub_impl!(Mul, mul, ClosedMulAssign;
13    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
14    const D; for; where;
15    self: &'a Scale<T, D>, right: &'b Scale<T, D>, Output = Scale<T, D>;
16    Scale::from(self.vector.component_mul(&right.vector));
17    'a, 'b);
18
19add_sub_impl!(Mul, mul, ClosedMulAssign;
20    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
21    const D; for; where;
22    self: &'a Scale<T, D>, right: Scale<T, D>, Output = Scale<T, D>;
23    Scale::from(self.vector.component_mul(&right.vector));
24    'a);
25
26add_sub_impl!(Mul, mul, ClosedMulAssign;
27    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
28    const D; for; where;
29    self: Scale<T, D>, right: &'b Scale<T, D>, Output = Scale<T, D>;
30    Scale::from(self.vector.component_mul(&right.vector));
31    'b);
32
33add_sub_impl!(Mul, mul, ClosedMulAssign;
34    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
35    const D; for; where;
36    self: Scale<T, D>, right: Scale<T, D>, Output = Scale<T, D>;
37    Scale::from(self.vector.component_mul(&right.vector)); );
38
39// Scale × scalar
40add_sub_impl!(Mul, mul, ClosedMulAssign;
41    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
42    const D; for; where;
43    self: &'a Scale<T, D>, right: T, Output = Scale<T, D>;
44    Scale::from(&self.vector * right);
45    'a);
46
47add_sub_impl!(Mul, mul, ClosedMulAssign;
48    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
49    const D; for; where;
50    self: Scale<T, D>, right: T, Output = Scale<T, D>;
51    Scale::from(self.vector * right); );
52
53// Scale × Point
54add_sub_impl!(Mul, mul, ClosedMulAssign;
55    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
56    const D; for; where;
57    self: &'a Scale<T, D>, right: &'b Point<T, D>, Output = Point<T, D>;
58    Point::from(self.vector.component_mul(&right.coords));
59    'a, 'b);
60
61add_sub_impl!(Mul, mul, ClosedMulAssign;
62    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
63    const D; for; where;
64    self: &'a Scale<T, D>, right: Point<T, D>, Output = Point<T, D>;
65    Point::from(self.vector.component_mul(&right.coords));
66    'a);
67
68add_sub_impl!(Mul, mul, ClosedMulAssign;
69    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
70    const D; for; where;
71    self: Scale<T, D>, right: &'b Point<T, D>, Output = Point<T, D>;
72    Point::from(self.vector.component_mul(&right.coords));
73    'b);
74
75add_sub_impl!(Mul, mul, ClosedMulAssign;
76    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
77    const D; for; where;
78    self: Scale<T, D>, right: Point<T, D>, Output = Point<T, D>;
79    Point::from(self.vector.component_mul(&right.coords)); );
80
81// Scale * Vector
82add_sub_impl!(Mul, mul, ClosedMulAssign;
83    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
84    const D; for; where;
85    self: &'a Scale<T, D>, right: &'b SVector<T, D>, Output = SVector<T, D>;
86    self.vector.component_mul(right);
87    'a, 'b);
88
89add_sub_impl!(Mul, mul, ClosedMulAssign;
90    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
91    const D; for; where;
92    self: &'a Scale<T, D>, right: SVector<T, D>, Output = SVector<T, D>;
93    self.vector.component_mul(&right);
94    'a);
95
96add_sub_impl!(Mul, mul, ClosedMulAssign;
97    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
98    const D; for; where;
99    self: Scale<T, D>, right: &'b SVector<T, D>, Output = SVector<T, D>;
100    self.vector.component_mul(right);
101    'b);
102
103add_sub_impl!(Mul, mul, ClosedMulAssign;
104    (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
105    const D; for; where;
106    self: Scale<T, D>, right: SVector<T, D>, Output = SVector<T, D>;
107    self.vector.component_mul(&right); );
108
109// Scale *= Scale
110add_sub_assign_impl!(MulAssign, mul_assign, ClosedMulAssign;
111    const D;
112    self: Scale<T, D>, right: &'b Scale<T, D>;
113    self.vector.component_mul_assign(&right.vector);
114    'b);
115
116add_sub_assign_impl!(MulAssign, mul_assign, ClosedMulAssign;
117    const D;
118    self: Scale<T, D>, right: Scale<T, D>;
119    self.vector.component_mul_assign(&right.vector); );
120
121// Scale ×= scalar
122add_sub_assign_impl!(MulAssign, mul_assign, ClosedMulAssign;
123    const D;
124    self: Scale<T, D>, right: T;
125    self.vector *= right; );