Question
Computer Graphics (Java) (Java Applet Please) Write a program that for four points A, B, C and P, which: - Draws a TRIANGLE formed by
Computer Graphics (Java) (Java Applet Please)
Write a program that for four points A, B, C and P, which:
- Draws a TRIANGLE formed by ABC and a small cross showing the position of P
- Displays a line of text indicating which of the following three cases applies: inside ABC, outside ABC, or on an edge of ABC.
The user will specify the four points by clicking!!!!
Picture for how it should look in the case P is inside ABC. Triangle ABC, point P is the crosshairs inside ABC so once it should display a line of text "Inside ABC".
Example Tools that can be edited on which may be helpful in implementation:
// Tools2D.java: Class to be used in other program files. // Uses: Point2D (Section 1.5).
class Tools2D { static float area2(Point2D a, Point2D b, Point2D c) { return (a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x); } static float distance2(Point2D p, Point2D q) { float dx = p.x - q.x, dy = p.y - q.y; return dx * dx + dy * dy; }
static boolean insideTriangle(Point2D a, Point2D b, Point2D c, Point2D p){ // ABC is assumed to be counter-clockwise return area2(a, b, p) >= 0 && area2(b, c, p) >= 0 && area2(c, a, p) >= 0; } /* static boolean intersect(Point2D a, Point2D b, Point2D p, Point2D q){ // Do P and Q lie on the different sides of the line through // A and B, while A and B lie on the different sides of the // line through P and Q? return area2(a, b, p) * area2(a, b, q)
Please take screenshots of the output. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started