Rogue: Savage Rats, a retro-themed dungeon crawler
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.
 
 
rogue-savage-rats/src/mightypork/utils/math/vect/VectMutable.java

125 lines
2.0 KiB

package mightypork.utils.math.vect;
import mightypork.utils.annotations.FactoryMethod;
/**
* Mutable coord
*
* @author MightyPork
*/
public abstract class VectMutable extends VectMath<VectMutable> { // returns itself on edit
/**
* Get a variable initialized as zero (0,0,0)
*
* @return new mutable vector
*/
@FactoryMethod
public static VectMutable zero()
{
return make(ZERO);
}
/**
* Get a variable initialized as one (1,1,1)
*
* @return one mutable vector
*/
@FactoryMethod
public static VectMutable one()
{
return make(ONE);
}
/**
* Make new from coords
*
* @param x X coordinate
* @param y Y coordinate
* @return mutable vector
*/
@FactoryMethod
public static VectMutable make(double x, double y)
{
return make(x, y, 0);
}
/**
* Make new as copy of another
*
* @param copied copied vec
* @return mutable vector
*/
@FactoryMethod
public static VectMutable make(Vect copied)
{
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
*/
@FactoryMethod
public static VectMutable make(double x, double y, double z)
{
return new VectMutableVariable(x, y, z);
}
public VectMutable reset()
{
return result(0, 0, 0);
}
/**
* Set coordinates to match other coord.
*
* @param copied coord whose coordinates are used
* @return result
*/
public VectMutable setTo(Vect copied)
{
return result(copied.x(), copied.y(), copied.z());
}
/**
* Set 2D coordinates.<br>
* Z is unchanged.
*
* @param x x coordinate
* @param y y coordinate
* @return result
*/
public VectMutable setTo(double x, double y)
{
return result(x, y, z());
}
/**
* Set coordinates.
*
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @return result
*/
public VectMutable setTo(double x, double y, double z)
{
return result(x, y, z);
}
}