Advertisement
advictoriam

Untitled

Jan 15th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public class Geometry
  2. {
  3.    /**
  4.       Computes the area of a triangle
  5.       @param x1 the x-coordinate of the first corner
  6.       @param y1 the y-coordinate of the first corner
  7.       @param x2 the x-coordinate of the second corner
  8.       @param y2 the y-coordinate of the second corner
  9.       @param x3 the x-coordinate of the third corner
  10.       @param y3 the y-coordinate of the third corner
  11.       @return the area of the triangle
  12.    */
  13.    public static double triangleArea(double x1, double y1,
  14.       double x2, double y2, double x3, double y3)
  15.    {
  16.       return Math.abs((x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)) / 2);
  17.    }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement