R/triangle.area.R

triangle.area = function(v1, v2, v3) {
  # Find the area of the triangle defined by the vertices v1, v2 and v3
  a = magnitude(v1 - v2)
  b = magnitude(v1 - v3)
  c = magnitude(v2 - v3)
  s = (a + b + c)/2
  return (sqrt(s*(s - a)*(s - b)*(s - c)))
}

Try the eggs package in your browser

Any scripts or data that you put into this service are public.

eggs documentation built on May 2, 2019, 5:23 p.m.