math.plane.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import type { DeepImmutable } from "../types";
  2. import { Vector3, Matrix } from "./math.vector";
  3. import type { IPlaneLike } from "./math.like";
  4. /**
  5. * Represents a plane by the equation ax + by + cz + d = 0
  6. */
  7. export declare class Plane implements IPlaneLike {
  8. private static _TmpMatrix;
  9. /**
  10. * Normal of the plane (a,b,c)
  11. */
  12. normal: Vector3;
  13. /**
  14. * d component of the plane
  15. */
  16. d: number;
  17. /**
  18. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  19. * @param a a component of the plane
  20. * @param b b component of the plane
  21. * @param c c component of the plane
  22. * @param d d component of the plane
  23. */
  24. constructor(a: number, b: number, c: number, d: number);
  25. /**
  26. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  27. */
  28. asArray(): number[];
  29. /**
  30. * @returns a new plane copied from the current Plane.
  31. */
  32. clone(): Plane;
  33. /**
  34. * @returns the string "Plane".
  35. */
  36. getClassName(): string;
  37. /**
  38. * @returns the Plane hash code.
  39. */
  40. getHashCode(): number;
  41. /**
  42. * Normalize the current Plane in place.
  43. * @returns the updated Plane.
  44. */
  45. normalize(): Plane;
  46. /**
  47. * Applies a transformation the plane and returns the result
  48. * @param transformation the transformation matrix to be applied to the plane
  49. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  50. */
  51. transform(transformation: DeepImmutable<Matrix>): Plane;
  52. /**
  53. * Compute the dot product between the point and the plane normal
  54. * @param point point to calculate the dot product with
  55. * @returns the dot product (float) of the point coordinates and the plane normal.
  56. */
  57. dotCoordinate(point: DeepImmutable<Vector3>): number;
  58. /**
  59. * Updates the current Plane from the plane defined by the three given points.
  60. * @param point1 one of the points used to construct the plane
  61. * @param point2 one of the points used to construct the plane
  62. * @param point3 one of the points used to construct the plane
  63. * @returns the updated Plane.
  64. */
  65. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66. /**
  67. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  68. * Note that for this function to work as expected you should make sure that:
  69. * - direction and the plane normal are normalized
  70. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  71. * @param direction the direction to check if the plane is facing
  72. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73. * @returns True if the plane is facing the given direction
  74. */
  75. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  76. /**
  77. * Calculates the distance to a point
  78. * @param point point to calculate distance to
  79. * @returns the signed distance (float) from the given point to the Plane.
  80. */
  81. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82. /**
  83. * Creates a plane from an array
  84. * @param array the array to create a plane from
  85. * @returns a new Plane from the given array.
  86. */
  87. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  88. /**
  89. * Creates a plane from three points
  90. * @param point1 point used to create the plane
  91. * @param point2 point used to create the plane
  92. * @param point3 point used to create the plane
  93. * @returns a new Plane defined by the three given points.
  94. */
  95. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  96. /**
  97. * Creates a plane from an origin point and a normal
  98. * @param origin origin of the plane to be constructed
  99. * @param normal normal of the plane to be constructed
  100. * @returns a new Plane the normal vector to this plane at the given origin point.
  101. */
  102. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  103. /**
  104. * Updates the given Plane "result" from an origin point and a normal.
  105. * @param origin origin of the plane to be constructed
  106. * @param normal the normalized normals of the plane to be constructed
  107. * @param result defines the Plane where to store the result
  108. * @returns result input
  109. */
  110. static FromPositionAndNormalToRef<T extends Plane>(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, result: T): T;
  111. /**
  112. * Calculates the distance from a plane and a point
  113. * @param origin origin of the plane to be constructed
  114. * @param normal normal of the plane to be constructed
  115. * @param point point to calculate distance to
  116. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  117. */
  118. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  119. }