Skip to content

Commit

Permalink
Add quad reflection unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zilmarinen committed Aug 30, 2024
1 parent 0100e5e commit c004f95
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Tests/MeshTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,28 @@ class MeshTests: XCTestCase {
XCTAssertFalse(bsp.containsPoint(point))
}
}

// MARK: Reflection

func testQuadReflectionAlongPlane() {

let quad = Polygon(unchecked: [
Vertex(Vector(-0.5, 1.0, 0.5), .unitY, Vector(0.0, 1.0), .black),
Vertex(Vector(0.5, 1.0, 0.5), .unitY, Vector(1.0, 1.0), .black),
Vertex(Vector(0.5, 1.0, -0.5), .unitY, Vector(1.0, 0.0), .white),
Vertex(Vector(-0.5, 1.0, -0.5), .unitY, Vector(0.0, 0.0), .white),
])

let expected = Polygon(unchecked: [
Vertex(Vector(-0.5, -1.0, -0.5), -.unitY, Vector(0.0, 0.0), .white),
Vertex(Vector(0.5, -1.0, -0.5), -.unitY, Vector(1.0, 0.0), .white),
Vertex(Vector(0.5, -1.0, 0.5), -.unitY, Vector(1.0, 1.0), .black),
Vertex(Vector(-0.5, -1.0, 0.5), -.unitY, Vector(0.0, 1.0), .black),
])

let reflection = quad.reflect(along: .xz)

XCTAssertEqual(reflection.plane.normal, -.unitY)
XCTAssertEqual(reflection.vertices, expected.vertices)
}
}

0 comments on commit c004f95

Please sign in to comment.