User Tools

Site Tools


mtr_addon:nte:js:math

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
mtr_addon:nte:js:math [2024/02/06 13:07] – added source Alexander Minkinmtr_addon:nte:js:math [2025/12/03 08:54] (current) – Matrix4f.multiply() does not take a Vector3f AmberFrost
Line 1: Line 1:
 ====== Math Utilities ====== ====== Math Utilities ======
 +
 This is not an introduction to the math functions of the standard JavaScript library. Instead, this is a set of useful classes provided by NTE to perform transformations for model rendering and other things. This is not an introduction to the math functions of the standard JavaScript library. Instead, this is a set of useful classes provided by NTE to perform transformations for model rendering and other things.
  
 ===== Vector3f ===== ===== Vector3f =====
 +
 A three-dimensional vector, that is, the coordinates (x, y, z). A three-dimensional vector, that is, the coordinates (x, y, z).
 +
 ^ Functions And Objects ^ Description ^ ^ Functions And Objects ^ Description ^
 | ''new Vector3f(x: float, y: float, z: float)'' | Creates an instance of the Vector3f class. | | ''new Vector3f(x: float, y: float, z: float)'' | Creates an instance of the Vector3f class. |
Line 25: Line 28:
  
 ===== Matrix4f ===== ===== Matrix4f =====
 +
 3D transformation matrix. Represents a transformation relationship that corresponds one point to another. For example, one can say "I want to rotate this model 90 degrees around the Y-axis and then move it 10 meters along the X-axis..." and such a set of transformation operations can be represented by a matrix. 3D transformation matrix. Represents a transformation relationship that corresponds one point to another. For example, one can say "I want to rotate this model 90 degrees around the Y-axis and then move it 10 meters along the X-axis..." and such a set of transformation operations can be represented by a matrix.
  
Line 30: Line 34:
  
 Scaling transformations are not supported. Scaling transformations are not supported.
 +
 ^ Functions ^ Description ^ ^ Functions ^ Description ^
 | ''new Matrix4f()'' | Returns the Matrix4f. Initially it is a unit matrix that has not undergone any transformations. | | ''new Matrix4f()'' | Returns the Matrix4f. Initially it is a unit matrix that has not undergone any transformations. |
Line 36: Line 41:
 | ''Matrix4f.rotate(axis: Vector3f, rad: float): void'' | Adds a transformation that rotates around some direction at the origin. Angles are in radians, positive values are counterclockwise, and axis needs to be a unit vector. | | ''Matrix4f.rotate(axis: Vector3f, rad: float): void'' | Adds a transformation that rotates around some direction at the origin. Angles are in radians, positive values are counterclockwise, and axis needs to be a unit vector. |
 | ''Matrix4f.rotateX(rad: float): void'' | Rotates along the X axis, the angle is specified in radians. Has counterparts for Y and Z. | | ''Matrix4f.rotateX(rad: float): void'' | Rotates along the X axis, the angle is specified in radians. Has counterparts for Y and Z. |
-| ''Matrix4f.multiply(other: Vector3f): void'' | Right-multiply another transformation matrix, which means that the transformation of that matrix is picked up after this one. [Translator's note: wth does that mean] |+| ''Matrix4f.multiply(other: Matrix4f): void'' | Right-multiply another transformation matrix, which means that the transformation of that matrix is picked up after this one. [Translator's note: wth does that mean] |
 | ''Matrix4f.transform(vec: Vector3f): Vector3f'' | Calculates which coordinate a coordinate will go to after applying this transformation. Returns a new Vector3f without moving the input. | | ''Matrix4f.transform(vec: Vector3f): Vector3f'' | Calculates which coordinate a coordinate will go to after applying this transformation. Returns a new Vector3f without moving the input. |
 | ''Matrix4f.transform3(vec: Vector3f): Vector3f'' | Same as above, but only counts rotations not translations. | | ''Matrix4f.transform3(vec: Vector3f): Vector3f'' | Same as above, but only counts rotations not translations. |
Line 44: Line 49:
  
 ===== Matrices ===== ===== Matrices =====
 +
 When rendering, there will be a need to "restore the transformation state of the previous step". For example, I will add a move-down transformation to render the bogie, but after rendering I will need to return to the pre-move transformation state to render other parts of the car. When rendering, there will be a need to "restore the transformation state of the previous step". For example, I will add a move-down transformation to render the bogie, but after rendering I will need to return to the pre-move transformation state to render other parts of the car.
  
Line 61: Line 67:
  
 ===== Source ===== ===== Source =====
-* https://www.zbx1425.cn/nautilus/mtr-nte/#/js-math+ 
 +[[https://www.zbx1425.cn/nautilus/mtr-nte/#/js-math]] 
  
mtr_addon/nte/js/math.txt · Last modified: 2025/12/03 08:54 by AmberFrost