You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
3.1 KiB
177 lines
3.1 KiB
11 years ago
|
package mightypork.utils.math.vect;
|
||
11 years ago
|
|
||
|
|
||
11 years ago
|
import mightypork.utils.math.animation.AnimDouble;
|
||
|
import mightypork.utils.math.animation.Easing;
|
||
|
|
||
|
|
||
11 years ago
|
/**
|
||
11 years ago
|
* Mutable coord
|
||
11 years ago
|
*
|
||
|
* @author MightyPork
|
||
|
*/
|
||
11 years ago
|
public abstract class VectMutable extends VectMath<VectMutable> { // returns itself on edit
|
||
|
|
||
11 years ago
|
/**
|
||
|
* Get a variable initialized as zero (0,0,0)
|
||
|
*
|
||
|
* @return new mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutable zero()
|
||
11 years ago
|
{
|
||
|
return make(ZERO);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Get a variable initialized as one (1,1,1)
|
||
|
*
|
||
|
* @return one mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutable one()
|
||
11 years ago
|
{
|
||
|
return make(ONE);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Make new from coords
|
||
|
*
|
||
|
* @param x X coordinate
|
||
|
* @param y Y coordinate
|
||
|
* @return mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutable make(double x, double y)
|
||
11 years ago
|
{
|
||
|
return make(x, y, 0);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Make new as copy of another
|
||
|
*
|
||
|
* @param copied copied vec
|
||
|
* @return mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutable make(Vect copied)
|
||
11 years ago
|
{
|
||
|
return make(copied.x(), copied.y(), copied.z());
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Make new from coords
|
||
|
*
|
||
|
* @param x X coordinate
|
||
|
* @param y Y coordinate
|
||
|
* @param z Z coordinate
|
||
|
* @return mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutable make(double x, double y, double z)
|
||
11 years ago
|
{
|
||
11 years ago
|
return new VectMutableImpl(x, y, z);
|
||
11 years ago
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Create an animated vector; This way different easing / settings can be
|
||
|
* specified for each coordinate.
|
||
|
*
|
||
|
* @param animX x animator
|
||
|
* @param animY y animator
|
||
|
* @param animZ z animator
|
||
|
* @return animated mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutableAnim makeAnim(AnimDouble animX, AnimDouble animY, AnimDouble animZ)
|
||
11 years ago
|
{
|
||
11 years ago
|
return new VectMutableAnim(animX, animY, animZ);
|
||
11 years ago
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Create an animated vector
|
||
|
*
|
||
|
* @param animStart initial positioon
|
||
|
* @param easing animation easing
|
||
|
* @return animated mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutableAnim makeAnim(Vect animStart, Easing easing)
|
||
11 years ago
|
{
|
||
11 years ago
|
return new VectMutableAnim(animStart, easing);
|
||
11 years ago
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Create an animated vector, initialized at 0,0,0
|
||
|
*
|
||
|
* @param easing animation easing
|
||
|
* @return animated mutable vector
|
||
|
*/
|
||
11 years ago
|
public static VectMutableAnim makeAnim(Easing easing)
|
||
11 years ago
|
{
|
||
11 years ago
|
return new VectMutableAnim(Vect.ZERO, easing);
|
||
11 years ago
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
11 years ago
|
public abstract VectMutable result(double x, double y, double z);
|
||
11 years ago
|
|
||
|
|
||
|
@Override
|
||
|
public abstract double x();
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public abstract double y();
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public abstract double z();
|
||
|
|
||
|
|
||
11 years ago
|
public VectMutable reset()
|
||
11 years ago
|
{
|
||
|
return result(0, 0, 0);
|
||
|
}
|
||
|
|
||
11 years ago
|
|
||
|
/**
|
||
|
* Set coordinates to match other coord.
|
||
|
*
|
||
|
* @param copied coord whose coordinates are used
|
||
|
* @return result
|
||
|
*/
|
||
11 years ago
|
public VectMutable setTo(Vect copied)
|
||
11 years ago
|
{
|
||
|
return result(copied.x(), copied.y(), copied.z());
|
||
|
}
|
||
11 years ago
|
|
||
|
|
||
|
/**
|
||
|
* Set 2D coordinates.<br>
|
||
|
* Z is unchanged.
|
||
|
*
|
||
|
* @param x x coordinate
|
||
|
* @param y y coordinate
|
||
|
* @return result
|
||
|
*/
|
||
11 years ago
|
public VectMutable setTo(double x, double y)
|
||
11 years ago
|
{
|
||
|
return result(x, y, z());
|
||
|
}
|
||
11 years ago
|
|
||
|
|
||
|
/**
|
||
|
* Set coordinates.
|
||
|
*
|
||
|
* @param x x coordinate
|
||
|
* @param y y coordinate
|
||
|
* @param z z coordinate
|
||
|
* @return result
|
||
|
*/
|
||
11 years ago
|
public VectMutable setTo(double x, double y, double z)
|
||
11 years ago
|
{
|
||
|
return result(x, y, z);
|
||
|
}
|
||
11 years ago
|
}
|