1#[cxx::bridge(namespace = "maliput::math")]
32pub mod ffi {
33 unsafe extern "C++" {
34 include!("cxx_utils/error_handling.h");
35 include!("math/math.h");
36
37 #[namespace = "maliput::math"]
38 type Vector3;
39 fn Vector3_new(x: f64, y: f64, z: f64) -> UniquePtr<Vector3>;
40 fn x(self: &Vector3) -> f64;
41 fn y(self: &Vector3) -> f64;
42 fn z(self: &Vector3) -> f64;
43 fn norm(self: &Vector3) -> f64;
44 fn normalize(self: Pin<&mut Vector3>);
45 fn Vector3_dot(v: &Vector3, w: &Vector3) -> f64;
46 fn Vector3_cross(v: &Vector3, w: &Vector3) -> UniquePtr<Vector3>;
47 fn Vector3_equals(v: &Vector3, w: &Vector3) -> bool;
48 fn Vector3_to_str(v: &Vector3) -> String;
49
50 type Vector4;
51 fn Vector4_new(x: f64, y: f64, z: f64, w: f64) -> UniquePtr<Vector4>;
52 fn x(self: &Vector4) -> f64;
53 fn y(self: &Vector4) -> f64;
54 fn z(self: &Vector4) -> f64;
55 fn w(self: &Vector4) -> f64;
56 fn norm(self: &Vector4) -> f64;
57 fn normalize(self: Pin<&mut Vector4>);
58 fn Vector4_dot(v: &Vector4, w: &Vector4) -> f64;
59 fn Vector4_equals(v: &Vector4, w: &Vector4) -> bool;
60 fn Vector4_to_str(v: &Vector4) -> String;
61
62 type Matrix3;
63 #[allow(clippy::too_many_arguments)]
64 fn Matrix3_new(
65 m00: f64,
66 m01: f64,
67 m02: f64,
68 m10: f64,
69 m11: f64,
70 m12: f64,
71 m20: f64,
72 m21: f64,
73 m22: f64,
74 ) -> UniquePtr<Matrix3>;
75 fn cofactor(self: &Matrix3, row: usize, col: usize) -> f64;
76 fn determinant(self: &Matrix3) -> f64;
77 fn is_singular(self: &Matrix3) -> bool;
78 fn Matrix3_row(m: &Matrix3, index: usize) -> UniquePtr<Vector3>;
79 fn Matrix3_col(m: &Matrix3, index: usize) -> UniquePtr<Vector3>;
80 fn Matrix3_cofactor_matrix(m: &Matrix3) -> UniquePtr<Matrix3>;
81 fn Matrix3_transpose(m: &Matrix3) -> UniquePtr<Matrix3>;
82 fn Matrix3_equals(m: &Matrix3, other: &Matrix3) -> bool;
83 fn Matrix3_adjoint(m: &Matrix3) -> UniquePtr<Matrix3>;
84 fn Matrix3_operator_mul(m: &Matrix3, other: &Matrix3) -> UniquePtr<Matrix3>;
85 fn Matrix3_inverse(m: &Matrix3) -> UniquePtr<Matrix3>;
86 fn Matrix3_operator_sum(m: &Matrix3, other: &Matrix3) -> UniquePtr<Matrix3>;
87 fn Matrix3_operator_sub(m: &Matrix3, other: &Matrix3) -> UniquePtr<Matrix3>;
88 fn Matrix3_operator_divide_by_scalar(m: &Matrix3, scalar: f64) -> UniquePtr<Matrix3>;
89 fn Matrix3_to_str(m: &Matrix3) -> String;
90
91 type Quaternion;
92 fn Quaternion_new(w: f64, x: f64, y: f64, z: f64) -> UniquePtr<Quaternion>;
93 fn w(self: &Quaternion) -> f64;
94 fn x(self: &Quaternion) -> f64;
95 fn y(self: &Quaternion) -> f64;
96 fn z(self: &Quaternion) -> f64;
97 fn dot(self: &Quaternion, other: &Quaternion) -> f64;
98 fn AngularDistance(self: &Quaternion, other: &Quaternion) -> f64;
99 fn norm(self: &Quaternion) -> f64;
100 fn normalize(self: Pin<&mut Quaternion>);
101 fn squared_norm(self: &Quaternion) -> f64;
102 fn Quaternion_vec(q: &Quaternion) -> UniquePtr<Vector3>;
103 fn Quaternion_coeffs(q: &Quaternion) -> UniquePtr<Vector4>;
104 fn Quaternion_Inverse(q: &Quaternion) -> UniquePtr<Quaternion>;
105 fn Quaternion_conjugate(q: &Quaternion) -> UniquePtr<Quaternion>;
106 fn Quaternion_ToRotationMatrix(q: &Quaternion) -> UniquePtr<Matrix3>;
107 fn Quaternion_TransformVector(q: &Quaternion, v: &Vector3) -> UniquePtr<Vector3>;
108 fn Quaternion_IsApprox(q: &Quaternion, other: &Quaternion, precision: f64) -> bool;
109 fn Quaternion_equals(q: &Quaternion, other: &Quaternion) -> bool;
110 fn Quaternion_to_str(q: &Quaternion) -> String;
111
112 type RollPitchYaw;
113 fn RollPitchYaw_new(roll: f64, pitch: f64, yaw: f64) -> UniquePtr<RollPitchYaw>;
114 fn roll_angle(self: &RollPitchYaw) -> f64;
115 fn pitch_angle(self: &RollPitchYaw) -> f64;
116 fn yaw_angle(self: &RollPitchYaw) -> f64;
117 fn vector(self: &RollPitchYaw) -> &Vector3;
118 fn RollPitchYaw_set(rpy: Pin<&mut RollPitchYaw>, roll: f64, pitch: f64, yaw: f64);
119 fn RollPitchYaw_SetFromQuaternion(rpy: Pin<&mut RollPitchYaw>, q: &Quaternion);
120 fn RollPitchYaw_ToQuaternion(rpy: &RollPitchYaw) -> UniquePtr<Quaternion>;
121 fn RollPitchYaw_ToMatrix(rpy: &RollPitchYaw) -> UniquePtr<Matrix3>;
122 fn RollPitchYaw_CalcRotationMatrixDt(rpy: &RollPitchYaw, rpyDt: &Vector3) -> UniquePtr<Matrix3>;
123 }
124}