Skip to content

Instantly share code, notes, and snippets.

@AndriyBas
Created November 9, 2016 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndriyBas/45993049964bcb941ea737f56fa48286 to your computer and use it in GitHub Desktop.
Save AndriyBas/45993049964bcb941ea737f56fa48286 to your computer and use it in GitHub Desktop.
boolean pointInTriangle(@NonNull PointF pt, @NonNull PointF v1,
@NonNull PointF v2, @NonNull PointF v3) {
boolean b1 = crossProduct(pt, v1, v2) < 0.0f;
boolean b2 = crossProduct(pt, v2, v3) < 0.0f;
boolean b3 = crossProduct(pt, v3, v1) < 0.0f;
return (b1 == b2) && (b2 == b3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment