SweepLineSegment.js 724 B

123456789101112131415161718192021222324252627
  1. export default class SweepLineSegment {
  2. constructor() {
  3. SweepLineSegment.constructor_.apply(this, arguments)
  4. }
  5. static constructor_() {
  6. this.edge = null
  7. this.pts = null
  8. this.ptIndex = null
  9. const edge = arguments[0], ptIndex = arguments[1]
  10. this.edge = edge
  11. this.ptIndex = ptIndex
  12. this.pts = edge.getCoordinates()
  13. }
  14. getMaxX() {
  15. const x1 = this.pts[this.ptIndex].x
  16. const x2 = this.pts[this.ptIndex + 1].x
  17. return x1 > x2 ? x1 : x2
  18. }
  19. getMinX() {
  20. const x1 = this.pts[this.ptIndex].x
  21. const x2 = this.pts[this.ptIndex + 1].x
  22. return x1 < x2 ? x1 : x2
  23. }
  24. computeIntersections(ss, si) {
  25. si.addIntersections(this.edge, this.ptIndex, ss.edge, ss.ptIndex)
  26. }
  27. }