File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,18 @@ impl Vector2F {
137
137
Vector2F ( self . 0 . abs ( ) )
138
138
}
139
139
140
+ /// Returns the reciprocal of the vector, `(1.0 / x, 1.0 / y)`.
141
+ #[ inline]
142
+ pub fn recip ( self ) -> Vector2F {
143
+ Vector2F :: splat ( 1.0 ) / self
144
+ }
145
+
146
+ /// Returns the counterclockwise angle of the vector from the +x axis.
147
+ #[ inline]
148
+ pub fn angle ( self ) -> f32 {
149
+ self . y ( ) . atan2 ( self . x ( ) )
150
+ }
151
+
140
152
/// Returns the coefficient when the given vector `a` is projected onto this one.
141
153
///
142
154
/// That is, if this vector is `v` and this function returns `c`, then `proj_v a = cv`. In
@@ -146,6 +158,12 @@ impl Vector2F {
146
158
a. dot ( self ) / self . square_length ( )
147
159
}
148
160
161
+ /// Returns the angle between the two vectors.
162
+ #[ inline]
163
+ pub fn angle_between ( self , a : Vector2F ) -> f32 {
164
+ self . projection_coefficient ( a) . acos ( )
165
+ }
166
+
149
167
#[ inline]
150
168
pub fn is_zero ( self ) -> bool {
151
169
self == Vector2F :: zero ( )
You can’t perform that action at this time.
0 commit comments