Added Line.Offset, Triangle.Offset and Triangle.Equals.

This commit is contained in:
Richard Davey 2017-03-31 01:40:38 +01:00
parent b3bced081a
commit 7bcdf669b8
5 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,12 @@
var Offset = function (line, x, y)
{
line.x1 += x;
line.y1 += y;
line.x2 += x;
line.y2 += y;
return line;
};
module.exports = Offset;

View file

@ -15,6 +15,7 @@ Line.Length = require('./Length');
Line.NormalAngle = require('./NormalAngle');
Line.NormalX = require('./NormalX');
Line.NormalY = require('./NormalY');
Line.Offset = require('./Offset');
Line.PerpSlope = require('./PerpSlope');
Line.Random = require('./Random');
Line.ReflectAngle = require('./ReflectAngle');

View file

@ -0,0 +1,13 @@
var Equals = function (triangle, toCompare)
{
return (
triangle.x1 === toCompare.x1 &&
triangle.y1 === toCompare.y1 &&
triangle.x2 === toCompare.x2 &&
triangle.y2 === toCompare.y2 &&
triangle.x3 === toCompare.x3 &&
triangle.y3 === toCompare.y3
);
};
module.exports = Equals;

View file

@ -0,0 +1,15 @@
var Offset = function (triangle, x, y)
{
triangle.x1 += x;
triangle.y1 += y;
triangle.x2 += x;
triangle.y2 += y;
triangle.x3 += x;
triangle.y3 += y;
return triangle;
};
module.exports = Offset;

View file

@ -11,7 +11,10 @@ Triangle.CircumCircle = require('./CircumCircle');
Triangle.Clone = require('./Clone');
Triangle.Contains = require('./Contains');
Triangle.ContainsPoint = require('./ContainsPoint');
Triangle.CopyFrom = require('./CopyFrom');
Triangle.Equals = require('./Equals');
Triangle.InCenter = require('./InCenter');
Triangle.Offset = require('./Offset');
Triangle.Random = require('./Random');
Triangle.Rotate = require('./Rotate');
Triangle.RotateAroundPoint = require('./RotateAroundPoint');