Skip to content

Instantly share code, notes, and snippets.

@hiroakioishi
Last active December 5, 2015 14:12
Show Gist options
  • Save hiroakioishi/89893e8346f7f63dd962 to your computer and use it in GitHub Desktop.
Save hiroakioishi/89893e8346f7f63dd962 to your computer and use it in GitHub Desktop.
ある点から平面までの距離
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