polynomials_on_simplices.calculus.angle module¶
Functionality related to angles and for computing angles between vectors.
-
class
Dial
[source]¶ Bases:
object
A dial pointing at a position on a circle, while remembering the total number of laps it has turned around.
-
compute_angle
(v0, v1)[source]¶ Compute the angle between two vectors.
Parameters: - v0 – First vector.
- v1 – Second vector.
Returns: Angle between the two vectors (in \([0, \pi]\)).
-
degrees_to_radians
(angle)[source]¶ Convert an angle from degrees to radians.
Parameters: angle – Angle in degrees. Returns: Corresponding angle in radians. Return type: float
-
direction
(a0, a1)[source]¶ Compute the direction to go from a0 to a1.
Parameters: - a0 – First angle (in the range \([-\pi, \pi)\)).
- a1 – Second angle (in the range \([-\pi, \pi)\)).
Returns: 1 if the shortest path from a0 to a1 goes anti-clockwise around the unit circle. -1 otherwise.
-
distance
(a0, a1)[source]¶ Compute the distance between two angles (minimum distance along the unit circle).
Parameters: - a0 – First angle (in the range \([-\pi, \pi)\)).
- a1 – Second angle (in the range \([-\pi, \pi)\)).
Returns: Distance between the angles.
-
is_parallel
(v0, v1)[source]¶ Check if two vectors are parallel.
Parameters: - v0 – First vector.
- v1 – Second vector.
Returns: True/False whether or not the two vectors are (approximately) parallel.
-
orthogonal_vector
(v)[source]¶ Compute a vector which is orthogonal to the input vector \(v\).
Note
The returned orthogonal vector \(v^{\perp}\) satisfies \(\| v^{\perp} \| \geq \frac{2}{n} \| v \|\), where \(n\) is the dimension of the input vector \(v\).
Parameters: v – Non-zero n-dimensional vector. Returns: n-dimensional vector which is orthogonal to the input vector. Return type: Numpy array
-
orthonormal_frame
(v, i=0)[source]¶ Compute an orthonormal frame R in 3d such that the i:th (i in {0, 1, 2}) column is parallel to the given vector v (\(R e_i = v, R^T R = R R^T = I\)). The two other columns could then be used as an orthonormal basis for the plane with normal v and which passes through the origin.
This is the unique rotation matrix R which rotates \(e_i\) to \(v\) without twist, i.e. vectors parallel to \(e_x \times v\) are kept fixed.
Parameters: - v – Non-zero 3d vector from which we compute the orthonormal frame (point where the derivative is evaluated).
- i (int) – Column of the orthonormal frame which should be parallel to the input vector (i in {0, 1, 2}).
Returns: Orthonormal frame (3 by 3 orthogonal matrix).
Return type:
-
radians_to_degrees
(angle)[source]¶ Convert an angle from radians to degrees.
Parameters: angle – Angle in radians. Returns: Corresponding angle in degrees. Return type: float