diff --git a/lib/components/Component/createDirection.js b/lib/components/Component/createDirection.js index aeead367..defee2d7 100644 --- a/lib/components/Component/createDirection.js +++ b/lib/components/Component/createDirection.js @@ -18,7 +18,6 @@ module.exports = function (theta, phi) { // a Direction // - // TODO rename to createDirection if (typeof theta !== 'number') { throw new Error('Invalid theta angle') } diff --git a/lib/components/Component/createDistance.js b/lib/components/Component/createDistance.js new file mode 100644 index 00000000..7e5791ea --- /dev/null +++ b/lib/components/Component/createDistance.js @@ -0,0 +1,21 @@ +const Distance = require('../../geometry/Distance') + +module.exports = function (dist) { + // @Component:createDistance(dist) + // + // Create a Distance relative to the component. + // + // Parameters + // dist + // a number, a distance in the coordinate space of the component. + // + // Return + // a Distance + // + + if (typeof dist !== 'number') { + throw new Error('Invalid distance. Must be a number.') + } + + return new Distance(this, dist) +} diff --git a/lib/components/Component/index.js b/lib/components/Component/index.js index 498c56f8..898fa11a 100644 --- a/lib/components/Component/index.js +++ b/lib/components/Component/index.js @@ -80,6 +80,7 @@ proto.bringToFront = require('./bringToFront') proto.createBasis = require('./createBasis') proto.createPoint = proto.at proto.createDirection = require('./createDirection') +proto.createDistance = require('./createDistance') proto.createOrientation = require('./createOrientation') proto.createVector = require('./createVector') // TODO proto.getFirstChild diff --git a/test/components/Component/geometryCreation.html b/test/components/Component/geometryCreation.html index fea39151..ed4bd8b9 100644 --- a/test/components/Component/geometryCreation.html +++ b/test/components/Component/geometryCreation.html @@ -12,35 +12,43 @@