Last active
December 5, 2015 14:12
-
-
Save hiroakioishi/89893e8346f7f63dd962 to your computer and use it in GitHub Desktop.
ある点から平面までの距離
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float calcDistancePointAndPlane (Vector3 p, Vector3 v0, Vector3 v1, Vector3 v2) { | |
Vector3 n = Vector3.Normalize (Vector3.Cross (v1 - v0, v2 - v1)); | |
Vector3 g = (v0 + v1 + v2) / 3.0f; | |
return Mathf.Abs (Vector3.Dot (n, p - g)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment