Spaces:
Running
Running
Download src/math/Plane.ts from bilca/gsplat_library: direct link, hf CLI and curl.
- Browser
- Download file 663 Bytes
-
https://huggingface.co/spaces/bilca/gsplat_library/resolve/main/src/math/Plane.ts
- Command line
-
hf download hf://spaces/bilca/gsplat_library/src/math/Plane.ts
-
curl -L -o Plane.ts https://huggingface.co/spaces/bilca/gsplat_library/resolve/main/src/math/Plane.ts
663 Bytes
| import { Vector3 } from "./Vector3"; | |
| class Plane { | |
| public readonly normal: Vector3; | |
| public readonly point: Vector3; | |
| constructor(normal: Vector3, point: Vector3) { | |
| this.normal = normal; | |
| this.point = point; | |
| } | |
| intersect(origin: Vector3, direction: Vector3): Vector3 | null { | |
| const denominator = this.normal.dot(direction); | |
| if (Math.abs(denominator) < 0.0001) { | |
| return null; | |
| } | |
| const t = this.normal.dot(this.point.subtract(origin)) / denominator; | |
| if (t < 0) { | |
| return null; | |
| } | |
| return origin.add(direction.multiply(t)); | |
| } | |
| } | |
| export { Plane }; | |