modeling/src/maths/line2/transform.js

  1. const vec2 = require('../vec2')
  2. const fromPoints = require('./fromPoints')
  3. const origin = require('./origin')
  4. const direction = require('./direction')
  5. /**
  6. * Transforms the given line using the given matrix.
  7. *
  8. * @param {line2} out - receiving line
  9. * @param {line2} line - line to transform
  10. * @param {mat4} matrix - matrix to transform with
  11. * @returns {line2} out
  12. * @alias module:modeling/maths/line2.transform
  13. */
  14. const transform = (out, line, matrix) => {
  15. const org = origin(line)
  16. const dir = direction(line)
  17. vec2.transform(org, org, matrix)
  18. vec2.transform(dir, dir, matrix)
  19. return fromPoints(out, org, dir)
  20. }
  21. module.exports = transform