Releases: pmmp/Math
Releases · pmmp/Math
1.0.0
Changes since 0.4.3
- Added
Facing::OFFSETconstant (map of facing directions to their coordinate offsets) - Added
AxisAlignedBB->offsetTowards()andAxisAlignedBB->offsetTowardsCopy()- moves the BB in the given direction by a specified distance - Modernize and cleanup code to PHP 8.0 standards
Despite the version bump to 1.0.0, this isn't a huge release. Staying on 0.x for so long was a mistake that needed to be corrected.
0.4.3
0.4.2
0.4.1
0.4.0
Changes since 0.3.x
- PHP 8.0 is now required.
- Native union types have been applied to the following
Vector3elements:__construct()getX()getY()getZ()add()subtract()maxPlainDistance()withComponents()x,yandzfields
Vector2xandyfields now use nativefloatproperty types.Vector2->__construct()parameters are now mandatory.- Added
Vector2->addVector(Vector2)andVector2->subtractVector(Vector2), replacing the overloaded behaviour ofadd()andsubtract(). Vector2->add()no longer acceptsVector2in the first argument (useaddVector()instead).Vector2->subtract()no longer acceptsVector2in the first argument (usesubtractVector()instead).Vector2->distance()no longer acceptsfloat, float(nowVector2is required).Vector2->distanceSquared()no longer acceptsfloat, float(nowVector2is required).Matrixhas been modernized. All cases that used to returnfalseon error now throw exceptions instead.Axis,AxisAlignedBB,Facing,Math,VectorMathandVoxelRayTraceare now final.
0.3.0
This is a feature release, featuring significant API changes compared to 0.2.x.
Changes since 0.2.x
New features
- Added
Facingclass, which allows using and manipulating 3DFacingvalues.Vector3::SIDE_*constants are removed and replaced withFacing::*constants.Vector3::getOppositeSide()is replaced byFacing::opposite().- Additional utilities like
Facing::axis(),Facing::isPositive(),Facing::rotate()etc are provided.
- Added
Axisclass.
Vector3
- Removed the following API methods:
getOppositeSide(): useFacing::opposite()insteadsetComponents(): mutatingVector3is now discouraged, and in the futureVector3will become immutable.
Vector3::SIDE_*constants have been removed (useFacinginstead).- Added the following static API methods:
maxComponents(): returns aVector3with the highest x, y and z values of all the vectors given.minComponents(): returns aVector3with the lowest x, y and z values of all the vectors given.sum(): returns aVector3with x, y and z equalling the sums of the x, y and z values of the given vectors respectively.
- Added the following dynamic API methods:
- Added
Vector3->sides(), which returns aGenerator<Facing, Vector3>for all axis-aligned sides of the vector. - Added
Vector3->sidesArray(), which returnsarray<Facing, Vector3>for all axis-aligned sides of the vector. - Added
Vector3->sidesAroundAxis(), which returnsGenerator<Facing, Vector3>for axis-aligned sides of the vector not on the given axis. - Added
Vector3->withComponents(), which allows easily creating a copy of aVector3while replacing one or more components of it.
- Added
Vector3->add()is split into two functions:Vector3->add()now requiresfloat, float, floatand has no optional parameters.Vector3->addVector()acceptsVector3, replacing the overloaded functionality ofVector3->add().
Vector3->subtract()is split into two functions:Vector3->subtract()now requiresfloat, float, floatand has no optional parameters.Vector3->subtractVector()acceptsVector3, replacing the overloaded functionality ofVector3->subtract().
AxisAlignedBB
AxisAlignedBB->__construct()now throwsInvalidArgumentExceptionif any of themincomponents are larger than their correspondingmaxcomponents.- Removed the following API methods:
setBounds(): modifyingAxisAlignedBBis now discouraged andAxisAlignedBBwill become immutable in the futuresetBB()
- Added the following dynamic API methods:
extend(): adds a length of distance to the given face of the bounding boxextendedCopy()trim(): removes a length of distance from the given face of the bounding boxtrimmedCopy()stretch(): adds a length of distance to both sides of the bounding box on the given axisstretchedCopy()squash(): removes a length of distance from both sides of the bounding box on the given axissquashedCopy()getXLength(): returns the difference betweenminXandmaxXgetYLength(): returns the difference betweenminYandmaxYgetZLength(): returns the difference betweenminZandmaxZisCube(): returns whether the bounding box's edges are all of approximately equal lengthgetVolume(): returns the amount of space inside the bounding box in cubic units
- Added the following static API methods:
one(): returns a newAxisAlignedBBwith min bounds0,0,0and max bounds1,1,1
0.2.6
0.2.5
0.2.4
Changes since 0.2.3
- Fixed determinant calculation for 1x1 matrix.
Vector3::subtract()now requires at least 1 parameter.Vector3::maxPlainDistance()now requires at least 1 parameter.- Populated missing type information for
Matrix,Vector3andAxisAlignedBB. - Now scanned with PHPStan level 8.