Skip to content

Instantly share code, notes, and snippets.

@adriancmiranda
Last active December 24, 2015 13:54
Show Gist options
  • Select an option

  • Save adriancmiranda/eccbcc0b9a42f4548fb4 to your computer and use it in GitHub Desktop.

Select an option

Save adriancmiranda/eccbcc0b9a42f4548fb4 to your computer and use it in GitHub Desktop.
// https://en.wikipedia.org/wiki/Altitude_(triangle)#Orthocenter
// Altitude in terms of the sides
this._h = (2*Math.sqrt(this._semiperimeter * (this._semiperimeter - this._distanceAB) * (this._semiperimeter - this._distanceBC) * (this._semiperimeter - this._distanceCA), 2));
this._ha = this._h / this._distanceAB;
this._hb = this._h / this._distanceBC;
this._hc = this._h / this._distanceCA;
this._altitudeAB = this._perpendicularSlopeAB * (x - this._c.x) + this._c.y;
this._altitudeBC = this._perpendicularSlopeBC * (x - this._a.x) + this._a.y;
this._altitudeCA = this._perpendicularSlopeCA * (x - this._b.x) + this._b.y;
var x = (this.area * 2) - (this.area * 2) * 2;
function bla(ax,ay,az, bx,by,bz, cx,cy,cz){
return (ax*by*cz + ay*bz*cx + az*bx*cy) - (ax*bz*cy + ay*bx*cz + az*by*cx);
}
var ocx = bla(
-(b.x * c.x) - (a.y * a.y), a.y, 1,
-(c.x * a.x) - (b.y * b.y), b.y, 1,
-(a.x * b.x) - (c.y * c.y), c.y, 1
) / x;
var ocy = bla(
a.x, -(a.x * a.x) - (b.y * c.y), 1,
b.x, -(b.x * b.x) - (c.y * a.y), 1,
c.x, -(c.x * c.x) - (a.y * b.y), 1
) / x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment