R/triangle.area.R

Defines functions triangle.area

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 egg package in your browser

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

egg documentation built on May 2, 2019, 5:55 p.m.