@@ -166,33 +166,33 @@ pub fn is_point_in_line(p &Point, a &Point, b &Point, zero f64, told f64, tolin
166
166
167
167
// pythagorean_theorem calculates the length of the hypotenuse given the lengths of the other two sides
168
168
pub fn pythagorean_theorem (a f64 , b f64 ) f64 {
169
- return math.sqrt (a * a + b * b)
169
+ return math.sqrt (a * a + b * b)
170
170
}
171
171
172
172
// euclidean_theorem calculates the lengths of segments created by the altitude to the hypotenuse
173
173
pub fn euclidean_theorem (a f64 , b f64 , c f64 ) (f64 , f64 ) {
174
- h := (a * b) / c
175
- p := (h * h) / a
176
- q := (h * h) / b
177
- return p, q
174
+ h := (a * b) / c
175
+ p := (h * h) / a
176
+ q := (h * h) / b
177
+ return p, q
178
178
}
179
179
180
180
// triangle_area_sine calculates the area of a triangle given two sides and the angle between them
181
181
pub fn triangle_area_sine (a f64 , b f64 , angle_rad f64 ) f64 {
182
- return 0.5 * a * b * math.sin (angle_rad)
182
+ return 0.5 * a * b * math.sin (angle_rad)
183
183
}
184
184
185
185
// triangle_missing_side calculates the length of the missing side of a triangle
186
186
// given two sides and the angle between them
187
187
pub fn triangle_missing_side (a f64 , b f64 , angle_rad f64 ) f64 {
188
- return math.sqrt (a * a + b * b - 2 * a * b * math.cos (angle_rad))
188
+ return math.sqrt (a * a + b * b - 2 * a * b * math.cos (angle_rad))
189
189
}
190
190
191
191
// triangle_area_from_points calculates the area of a triangle given its three vertices
192
192
pub fn triangle_area_from_points (p1 & Point, p2 & Point, p3 & Point) f64 {
193
- a := dist_point_point (p1 , p2 )
194
- b := dist_point_point (p2 , p3 )
195
- c := dist_point_point (p3 , p1 )
196
- s := (a + b + c) / 2 // semi-perimeter
197
- return math.sqrt (s * (s - a) * (s - b) * (s - c))
193
+ a := dist_point_point (p1 , p2 )
194
+ b := dist_point_point (p2 , p3 )
195
+ c := dist_point_point (p3 , p1 )
196
+ s := (a + b + c) / 2 // semi-perimeter
197
+ return math.sqrt (s * (s - a) * (s - b) * (s - c))
198
198
}
0 commit comments