Skip to content

Commit

Permalink
Fixing Bounds3 correct reference to Matrix4, see #125
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Jul 30, 2024
1 parent b06711c commit f9c40fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
24 changes: 11 additions & 13 deletions js/Bounds3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import IOType from '../../tandem/js/types/IOType.js';
import NumberIO from '../../tandem/js/types/NumberIO.js';
import dot from './dot.js';
import Vector3 from './Vector3.js';
import Matrix3 from './Matrix3.js';
import Matrix4 from './Matrix4.js';

class Bounds3 {

Expand Down Expand Up @@ -511,9 +511,8 @@ class Bounds3 {
*
* This is the immutable form of the function transform(). This will return a new bounds, and will not modify
* this bounds.
* // TODO: Should be Matrix4 type, https://github.com/phetsims/dot/issues/125
*/
public transformed( matrix: Matrix3 ): Bounds3 {
public transformed( matrix: Matrix4 ): Bounds3 {
return this.copy().transform( matrix );
}

Expand Down Expand Up @@ -874,9 +873,8 @@ class Bounds3 {
*
* This is the mutable form of the function transformed(). This will mutate (change) this bounds, in addition to returning
* this bounds itself.
* // TODO: should be Matrix4 type, https://github.com/phetsims/dot/issues/125
*/
public transform( matrix: Matrix3 ): Bounds3 {
public transform( matrix: Matrix4 ): Bounds3 {
// do nothing
if ( this.isEmpty() ) {
return this;
Expand Down Expand Up @@ -907,14 +905,14 @@ class Bounds3 {
maxZ = Math.max( maxZ, vector.z );
}

withIt( matrix.multiplyVector3( vector.setXYZ( this.minX, this.minY, this.minZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.minX, this.maxY, this.minZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.maxX, this.minY, this.minZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.maxX, this.maxY, this.minZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.minX, this.minY, this.maxZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.minX, this.maxY, this.maxZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.maxX, this.minY, this.maxZ ) ) );
withIt( matrix.multiplyVector3( vector.setXYZ( this.maxX, this.maxY, this.maxZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.minX, this.minY, this.minZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.minX, this.maxY, this.minZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.maxX, this.minY, this.minZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.maxX, this.maxY, this.minZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.minX, this.minY, this.maxZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.minX, this.maxY, this.maxZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.maxX, this.minY, this.maxZ ) ) );
withIt( matrix.timesVector3( vector.setXYZ( this.maxX, this.maxY, this.maxZ ) ) );
return this.setMinMax( minX, minY, minZ, maxX, maxY, maxZ );
}

Expand Down
10 changes: 10 additions & 0 deletions js/Matrix4.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ class Matrix4 {
return this.entries[ 15 ];
}

/**
* Returns whether this matrix is an identity matrix.
* @public
*
* @returns {boolean}
*/
isIdentity() {
return this.type === Types.IDENTITY || this.equals( Matrix4.IDENTITY );
}

/**
* Returns whether all of this matrix's entries are finite (non-infinite and non-NaN).
* @public
Expand Down

0 comments on commit f9c40fd

Please sign in to comment.