Skip to content

Commit

Permalink
Fix area calculation of Face3
Browse files Browse the repository at this point in the history
There seemed to be a bug in area calculation in Face3::get_area()-function. It returned the area of "imaginary" parallelogram instead of the triangle. Therefore the area returned was twice the real area. This manifested itself when using a hydro module for godot ( https://gitlab.com/ringtechsolutions/godot-tools/hydro/hydro ) causing the buoyancy to be two times the expected value.

"Reference": http://www.maths.usyd.edu.au/u/MOW/vectors/vectors-11/v-11-7.html
  • Loading branch information
GNSS-Stylist authored and akien-mga committed Apr 28, 2021
1 parent 35a8693 commit a165eed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/math/face3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Vector3 Face3::get_median_point() const {
}

real_t Face3::get_area() const {
return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length();
return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length() * 0.5;
}

ClockDirection Face3::get_clock_dir() const {
Expand Down

0 comments on commit a165eed

Please sign in to comment.