modeling/src/geometries/poly2/flip.js

  1. const create = require('./create')
  2. /**
  3. * Flip the give polygon, rotating the opposite direction.
  4. *
  5. * @param {poly2} polygon - the polygon to flip
  6. * @returns {poly2} a new polygon
  7. * @alias module:modeling/geometries/poly2.flip
  8. */
  9. const flip = (polygon) => {
  10. const vertices = polygon.vertices.slice().reverse()
  11. return create(vertices)
  12. }
  13. module.exports = flip