Java examples for java.lang:Math Geometry Shape
Calculate area of triangle given lengths of sides.
/***//from w w w .j a v a 2s. c o m * Copyright (C) 2010 Johan Henriksson * This code is under the Endrov / BSD license. See www.endrov.net * for the full text and how to cite. */ import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.vecmath.Vector3d; public class Main{ /** * Calculate area of triangle given lengths of sides. * Uses Heron's formula. */ public static double triangleAreaUsingSides(double a, double b, double c) { double s = (a + b + c) / 2; return Math.sqrt(s * (s - a) * (s - b) * (s - c)); } }