From 7bcdf669b8b286907a9bb64739956e809c6d809e Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 31 Mar 2017 01:40:38 +0100 Subject: [PATCH] Added Line.Offset, Triangle.Offset and Triangle.Equals. --- v3/src/geom/line/Offset.js | 12 ++++++++++++ v3/src/geom/line/index.js | 1 + v3/src/geom/triangle/Equals.js | 13 +++++++++++++ v3/src/geom/triangle/Offset.js | 15 +++++++++++++++ v3/src/geom/triangle/index.js | 3 +++ 5 files changed, 44 insertions(+) create mode 100644 v3/src/geom/line/Offset.js create mode 100644 v3/src/geom/triangle/Equals.js create mode 100644 v3/src/geom/triangle/Offset.js diff --git a/v3/src/geom/line/Offset.js b/v3/src/geom/line/Offset.js new file mode 100644 index 000000000..dea127e31 --- /dev/null +++ b/v3/src/geom/line/Offset.js @@ -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; diff --git a/v3/src/geom/line/index.js b/v3/src/geom/line/index.js index e05a0e668..274ea8ba0 100644 --- a/v3/src/geom/line/index.js +++ b/v3/src/geom/line/index.js @@ -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'); diff --git a/v3/src/geom/triangle/Equals.js b/v3/src/geom/triangle/Equals.js new file mode 100644 index 000000000..126f289df --- /dev/null +++ b/v3/src/geom/triangle/Equals.js @@ -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; diff --git a/v3/src/geom/triangle/Offset.js b/v3/src/geom/triangle/Offset.js new file mode 100644 index 000000000..e6f074595 --- /dev/null +++ b/v3/src/geom/triangle/Offset.js @@ -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; diff --git a/v3/src/geom/triangle/index.js b/v3/src/geom/triangle/index.js index b199f5154..306dcfaf8 100644 --- a/v3/src/geom/triangle/index.js +++ b/v3/src/geom/triangle/index.js @@ -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');