parent
							
								
									0f2cb0b985
								
							
						
					
					
						commit
						dca4b58b86
					
				@ -1,44 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Constraint cache | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 * @param <C> constraint type | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface ConstraintCache<C> extends Pollable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Called after the cache has changed value (and digest). | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	void onConstraintChanged(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return the cached value | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	C getCacheSource(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Enable caching & digest caching | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param yes enable caching | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	void enableCaching(boolean yes); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return true if caching is on | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	boolean isCachingEnabled(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Update cached value and cached digest (if digest caching is enabled).<br> | 
					 | 
				
			||||||
	 * source constraint is polled beforehand. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	void poll(); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,60 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Parametrized implementation of a {@link Digestable} | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 * @param <D> digest class
 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class DigestCache<D> implements Digestable<D> { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private D last_digest; | 
					 | 
				
			||||||
	private boolean caching_enabled = false; | 
					 | 
				
			||||||
	private boolean dirty = true; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final D digest() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (caching_enabled) { | 
					 | 
				
			||||||
			if (dirty || last_digest == null) { | 
					 | 
				
			||||||
				last_digest = createDigest(); | 
					 | 
				
			||||||
				dirty = false; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			return last_digest; | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return createDigest(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return fresh new digest | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	protected abstract D createDigest(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void enableDigestCaching(boolean yes) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		caching_enabled = yes; | 
					 | 
				
			||||||
		markDigestDirty(); // mark dirty
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final boolean isDigestCachingEnabled() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return caching_enabled; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void markDigestDirty() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		dirty = true; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,60 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * Interface for constraints that support digests. Digest is a small data object | 
					 | 
				
			||||||
 * with final fields, typically primitive, used for processing (such as | 
					 | 
				
			||||||
 * rendering or other very frequent operations). | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * Taking a digest is expensive, so if it needs to be done often and the value | 
					 | 
				
			||||||
 * changes are deterministic (such as, triggered by timing event or screen | 
					 | 
				
			||||||
 * resize), it's useful to cache the last digest and reuse it until such an | 
					 | 
				
			||||||
 * event occurs again. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * Implementing class typically needs a field to store the last digest, a flag | 
					 | 
				
			||||||
 * that digest caching is enabled, and a flag that a digest is dirty. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 * @param <D> digest class
 | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface Digestable<D> { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Take a digest. If digest caching is enabled and the cached digest is | 
					 | 
				
			||||||
	 * marked as dirty, a new one should be made. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @return digest | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public D digest(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * <p> | 
					 | 
				
			||||||
	 * Toggle digest caching. | 
					 | 
				
			||||||
	 * </p> | 
					 | 
				
			||||||
	 * <p> | 
					 | 
				
			||||||
	 * To trigger update of the cache, call the <code>poll()</code> method. | 
					 | 
				
			||||||
	 * </p> | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param yes | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	void enableDigestCaching(boolean yes); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return true if digest caching is enabled. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	boolean isDigestCachingEnabled(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * If digest caching is enabled, mark current cached value as "dirty". Dirty | 
					 | 
				
			||||||
	 * digest should be re-created next time a value is requested.<br> | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	void markDigestDirty(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,15 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Can be asked to update it's state | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface Pollable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Update internal state | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	void poll(); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,47 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.LinkedHashSet; | 
					 | 
				
			||||||
import java.util.Set; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Used to poll a number of {@link Pollable}s | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class Poller implements Pollable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Set<Pollable> pollables = new LinkedHashSet<>(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Add a pollable | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param p pollable | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void add(Pollable p) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		pollables.add(p); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Remove a pollalbe | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param p pollable | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void remove(Pollable p) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		pollables.remove(p); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void poll() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		for (final Pollable p : pollables) { | 
					 | 
				
			||||||
			p.poll(); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,760 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.annot.FactoryMethod; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.Calc; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.DigestCache; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.Digestable; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.caching.NumCache; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.caching.NumDigest; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumVar; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.proxy.NumBound; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.proxy.NumBoundAdapter; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public abstract class Num implements NumBound, Digestable<NumDigest> { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public static final NumConst ZERO = Num.make(0); | 
					 | 
				
			||||||
	public static final NumConst ONE = Num.make(1); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@FactoryMethod | 
					 | 
				
			||||||
	public static Num make(NumBound bound) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new NumBoundAdapter(bound); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@FactoryMethod | 
					 | 
				
			||||||
	public static NumConst make(double value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new NumConst(value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@FactoryMethod | 
					 | 
				
			||||||
	public static NumVar makeVar() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return makeVar(0); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@FactoryMethod | 
					 | 
				
			||||||
	public static NumVar makeVar(double value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new NumVar(value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@FactoryMethod | 
					 | 
				
			||||||
	public static NumVar makeVar(Num copied) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new NumVar(copied.value()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private Num p_ceil; | 
					 | 
				
			||||||
	private Num p_floor; | 
					 | 
				
			||||||
	private Num p_sgn; | 
					 | 
				
			||||||
	private Num p_round; | 
					 | 
				
			||||||
	private Num p_atan; | 
					 | 
				
			||||||
	private Num p_acos; | 
					 | 
				
			||||||
	private Num p_asin; | 
					 | 
				
			||||||
	private Num p_tan; | 
					 | 
				
			||||||
	private Num p_cos; | 
					 | 
				
			||||||
	private Num p_sin; | 
					 | 
				
			||||||
	private Num p_cbrt; | 
					 | 
				
			||||||
	private Num p_sqrt; | 
					 | 
				
			||||||
	private Num p_cube; | 
					 | 
				
			||||||
	private Num p_square; | 
					 | 
				
			||||||
	private Num p_neg; | 
					 | 
				
			||||||
	private Num p_abs; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final DigestCache<NumDigest> dc = new DigestCache<NumDigest>() { | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		@Override | 
					 | 
				
			||||||
		protected NumDigest createDigest() | 
					 | 
				
			||||||
		{ | 
					 | 
				
			||||||
			return new NumDigest(Num.this); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	}; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst freeze() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new NumConst(value()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Wrap this constraint into a caching adapter. Value will stay fixed (ie. | 
					 | 
				
			||||||
	 * no re-calculations) until cache receives a poll() call. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @return the caching adapter | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public NumCache cached() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new NumCache(this); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get a snapshot of the current state, to be used for processing. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @return digest | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumDigest digest() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return dc.digest(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void enableDigestCaching(boolean yes) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		dc.enableDigestCaching(yes); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public boolean isDigestCachingEnabled() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return dc.isDigestCachingEnabled(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void markDigestDirty() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		dc.markDigestDirty(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Num getNum() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return this; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return the number | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract double value(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num add(final double addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			private final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() + addend; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num add(final Num addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() + addend.value(); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num sub(final double subtrahend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return add(-subtrahend); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num abs() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_abs == null) p_abs = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.abs(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_abs; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num sub(final Num subtrahend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() - subtrahend.value(); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num div(final double factor) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(1 / factor); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num div(final Num factor) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() / factor.value(); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num mul(final double factor) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			private final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() * factor; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num mul(final Num factor) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() * factor.value(); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num average(final double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return (t.value() + other) / 2; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num average(final Num other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return (t.value() + other.value()) / 2; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num perc(final double percent) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(percent / 100D); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num perc(final Num percent) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return t.value() * (percent.value() / 100); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num cos() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_cos == null) p_cos = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.cos(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_cos; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num acos() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_acos == null) p_acos = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.acos(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_acos; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num sin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_sin == null) p_sin = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.sin(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_sin; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num asin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_asin == null) p_asin = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.asin(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_asin; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num tan() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_tan == null) p_tan = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.tan(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_tan; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num atan() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_atan == null) p_atan = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.atan(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_atan; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num cbrt() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_cbrt == null) p_cbrt = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.cbrt(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_cbrt; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num sqrt() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_sqrt == null) p_sqrt = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.sqrt(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_sqrt; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num neg() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_neg == null) p_neg = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return -1 * t.value(); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_neg; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num round() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_round == null) p_round = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.round(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_round; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num floor() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_floor == null) p_floor = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.floor(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_floor; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num ceil() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_ceil == null) p_ceil = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.round(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_ceil; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num pow(final double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.pow(t.value(), other); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num pow(final Num power) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.pow(t.value(), power.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num cube() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_cube == null) p_cube = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				final double v = t.value(); | 
					 | 
				
			||||||
				return v * v * v; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_cube; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num square() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_square == null) p_square = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				final double v = t.value(); | 
					 | 
				
			||||||
				return v * v; | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_square; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num half() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(0.5); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num max(final double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.max(t.value(), other); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num max(final Num other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.max(t.value(), other.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num min(final Num other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.min(t.value(), other.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num min(final double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.min(t.value(), other); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public Num signum() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (p_sgn == null) p_sgn = new Num() { | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			final Num t = Num.this; | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			@Override | 
					 | 
				
			||||||
			public double value() | 
					 | 
				
			||||||
			{ | 
					 | 
				
			||||||
				return Math.signum(t.value()); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
		}; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return p_sgn; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public boolean isNegative() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return value() < 0; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public boolean isPositive() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return value() > 0; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public boolean isZero() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return value() == 0; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public int hashCode() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		final int prime = 31; | 
					 | 
				
			||||||
		int result = 1; | 
					 | 
				
			||||||
		long temp; | 
					 | 
				
			||||||
		temp = Double.doubleToLongBits(value()); | 
					 | 
				
			||||||
		result = prime * result + (int) (temp ^ (temp >>> 32)); | 
					 | 
				
			||||||
		return result; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public boolean equals(Object obj) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (this == obj) return true; | 
					 | 
				
			||||||
		if (obj == null) return false; | 
					 | 
				
			||||||
		if (!(obj instanceof Num)) return false; | 
					 | 
				
			||||||
		final Num other = (Num) obj; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return value() == other.value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public String toString() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Calc.toString(value()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return vect with both coords of this size | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public Vect toVectXY() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Vect.make(this); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,270 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.caching.NumDigest; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Constant number.<br> | 
					 | 
				
			||||||
 * It's arranged so that operations with constant arguments yield constant | 
					 | 
				
			||||||
 * results. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class NumConst extends Num { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final double value; | 
					 | 
				
			||||||
	private NumDigest digest; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	NumConst(Num copied) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.value = copied.value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	NumConst(double value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.value = value; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double value() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return value; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @deprecated No good to copy a constant. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	@Deprecated | 
					 | 
				
			||||||
	public NumConst freeze() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return this; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumDigest digest() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (digest != null) ? digest : (digest = super.digest()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst add(double addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(value() + addend); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst add(NumConst addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(value + addend.value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst sub(double subtrahend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return add(-subtrahend); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst sub(NumConst addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(value - addend.value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst mul(double factor) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(value() * factor); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst mul(NumConst addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(value * addend.value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst div(double factor) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(1 / factor); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst div(NumConst addend) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(value / addend.value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst perc(double percents) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(percents / 100); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst neg() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(-1); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst abs() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.abs(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst max(double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.max(value(), other)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst min(double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.min(value(), other)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst pow(double power) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.pow(value(), power)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst square() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		final double v = value(); | 
					 | 
				
			||||||
		return Num.make(v * v); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst cube() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		final double v = value(); | 
					 | 
				
			||||||
		return Num.make(v * v * v); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst sqrt() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.sqrt(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst cbrt() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.cbrt(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst sin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.sin(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst cos() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.cos(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst tan() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.tan(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst asin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.asin(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst acos() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.acos(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst atan() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.atan(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst signum() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.signum(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst average(double other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make((value() + other) / 2); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst average(NumConst other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.average(other).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst round() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.round(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst ceil() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.ceil(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst floor() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Num.make(Math.floor(value())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst half() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return mul(0.5); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,49 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.ArrayList; | 
					 | 
				
			||||||
import java.util.List; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Expandable sum of multiple numbers | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class NumSum extends Num { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final List<Num> summands = new ArrayList<>(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double value() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		double v = 0; | 
					 | 
				
			||||||
		for (final Num n : summands) { | 
					 | 
				
			||||||
			if (n != null) v += n.value(); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		return v; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Add a number to the sum | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param summand added number | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void addSummand(Num summand) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		summands.add(summand); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Add a number to the sum | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param summand added number | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void addSummand(double summand) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		summands.add(Num.make(summand)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,84 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.ConstraintCache; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumVar; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.proxy.NumAdapter; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * A Num cache. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * Values are held in a caching VectVar, and digest caching is enabled by | 
					 | 
				
			||||||
 * default. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class AbstractNumCache extends NumAdapter implements ConstraintCache<Num> { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final NumVar cache = Num.makeVar(); | 
					 | 
				
			||||||
	private boolean inited = false; | 
					 | 
				
			||||||
	private boolean cachingEnabled = true; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public AbstractNumCache() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		enableDigestCaching(true); // it changes only on poll
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected final Num getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (!inited) markDigestDirty(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return (cachingEnabled ? cache : getCacheSource()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void poll() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		inited = true; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// poll source
 | 
					 | 
				
			||||||
		final Num source = getCacheSource(); | 
					 | 
				
			||||||
		source.markDigestDirty(); // poll cached
 | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// store source value
 | 
					 | 
				
			||||||
		cache.setTo(source); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// mark my digest dirty
 | 
					 | 
				
			||||||
		markDigestDirty(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		onConstraintChanged(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public abstract void onConstraintChanged(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public abstract Num getCacheSource(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void enableCaching(boolean yes) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		cachingEnabled = yes; | 
					 | 
				
			||||||
		enableDigestCaching(yes); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final boolean isCachingEnabled() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return cachingEnabled; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,37 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.annot.DefaultImpl; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Num cache implementation | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class NumCache extends AbstractNumCache { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Num source; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumCache(Num source) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.source = source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final Num getCacheSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	@DefaultImpl | 
					 | 
				
			||||||
	public void onConstraintChanged() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,23 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class NumDigest { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public final double value; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumDigest(Num num) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.value = num.value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public String toString() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return String.format("Num(%.1f)", value); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,41 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.mutable; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Mutable numeric variable | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class NumMutable extends Num { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Assign a value | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param value new value | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setTo(double value); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Assign a value | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param value new value | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(Num value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(value.value()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set to zero | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void reset() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(0); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,42 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.mutable; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Mutable numeric variable. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class NumVar extends NumMutable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private double value; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumVar(Num value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this(value.value()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumVar(double value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.value = value; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double value() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return value; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setTo(double value) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.value = value; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,18 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public abstract class NumAdapter extends Num { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	protected abstract Num getSource(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double value() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return getSource().value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,19 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Numeric constraint | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface NumBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return current value | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Num getNum(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,36 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class NumBoundAdapter extends NumAdapter implements PluggableNumBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private NumBound backing = null; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumBoundAdapter() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumBoundAdapter(NumBound bound) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		backing = bound; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setNum(NumBound num) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.backing = num; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected Num getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return backing.getNum(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,24 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class NumProxy extends NumAdapter { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Num source; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumProxy(Num source) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.source = source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected Num getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,16 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Pluggable numeric constraint | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface PluggableNumBound extends NumBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @param num bound to set | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	abstract void setNum(NumBound num); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
									
										
											File diff suppressed because it is too large
											Load Diff
										
									
								
							
						@ -1,486 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.NumConst; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.caching.RectDigest; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.VectConst; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Rectangle with constant bounds, that can never change.<br> | 
					 | 
				
			||||||
 * It's arranged so that operations with constant arguments yield constant | 
					 | 
				
			||||||
 * results. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class RectConst extends Rect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final VectConst pos; | 
					 | 
				
			||||||
	private final VectConst size; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	// cached with lazy loading
 | 
					 | 
				
			||||||
	private NumConst v_b; | 
					 | 
				
			||||||
	private NumConst v_r; | 
					 | 
				
			||||||
	private VectConst v_br; | 
					 | 
				
			||||||
	private VectConst v_tc; | 
					 | 
				
			||||||
	private VectConst v_tr; | 
					 | 
				
			||||||
	private VectConst v_cl; | 
					 | 
				
			||||||
	private VectConst v_c; | 
					 | 
				
			||||||
	private VectConst v_cr; | 
					 | 
				
			||||||
	private VectConst v_bl; | 
					 | 
				
			||||||
	private VectConst v_bc; | 
					 | 
				
			||||||
	private RectConst v_round; | 
					 | 
				
			||||||
	private RectConst v_edge_l; | 
					 | 
				
			||||||
	private RectConst v_edge_r; | 
					 | 
				
			||||||
	private RectConst v_edge_t; | 
					 | 
				
			||||||
	private RectConst v_edge_b; | 
					 | 
				
			||||||
	private RectDigest digest; | 
					 | 
				
			||||||
	private RectConst v_floor; | 
					 | 
				
			||||||
	private RectConst v_ceil; | 
					 | 
				
			||||||
	private RectConst v_axis_v; | 
					 | 
				
			||||||
	private RectConst v_axis_h; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Create at given origin, with given size. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x | 
					 | 
				
			||||||
	 * @param y | 
					 | 
				
			||||||
	 * @param width | 
					 | 
				
			||||||
	 * @param height | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	RectConst(double x, double y, double width, double height) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.pos = Vect.make(x, y); | 
					 | 
				
			||||||
		this.size = Vect.make(width, height); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Create at given origin, with given size. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param origin | 
					 | 
				
			||||||
	 * @param size | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	RectConst(Vect origin, Vect size) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.pos = origin.freeze(); | 
					 | 
				
			||||||
		this.size = size.freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Create at given origin, with given size. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param another other coord | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	RectConst(Rect another) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.pos = another.origin().freeze(); | 
					 | 
				
			||||||
		this.size = another.size().freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @deprecated it's useless to copy a constant | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	@Deprecated | 
					 | 
				
			||||||
	public RectConst freeze() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return this; // already constant
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectDigest digest() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (digest != null) ? digest : (digest = super.digest()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst origin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst size() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return size; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst move(Vect move) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return move(move.x(), move.y()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst move(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return Rect.make(pos.add(x, y), size); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst move(NumConst x, NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.move(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst shrink(double left, double right, double top, double bottom) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrink(left, right, top, bottom).freeze(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst grow(double left, double right, double top, double bottom) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.grow(left, right, top, bottom).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst round() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_round != null) ? v_round : (v_round = Rect.make(pos.round(), size.round())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst floor() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_floor != null) ? v_floor : (v_floor = Rect.make(pos.floor(), size.floor())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst ceil() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_ceil != null) ? v_ceil : (v_ceil = Rect.make(pos.ceil(), size.ceil())); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst x() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos.xn(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst y() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos.yn(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst width() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return size.xn(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst height() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return size.yn(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst left() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos.xn(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst right() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_r != null) ? v_r : (v_r = super.right().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst top() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos.yn(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst bottom() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_b != null) ? v_b : (v_b = super.bottom().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst topLeft() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst topCenter() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_tc != null) ? v_tc : (v_tc = super.topCenter().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst topRight() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_tr != null) ? v_tr : (v_tr = super.topRight().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst centerLeft() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_cl != null) ? v_cl : (v_cl = super.centerLeft().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst center() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_c != null) ? v_c : (v_c = super.center().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst centerRight() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_cr != null) ? v_cr : (v_cr = super.centerRight().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst bottomLeft() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_bl != null) ? v_bl : (v_bl = super.bottomLeft().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst bottomCenter() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_bc != null) ? v_bc : (v_bc = super.bottomCenter().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst bottomRight() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_br != null) ? v_br : (v_br = super.bottomRight().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst leftEdge() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_edge_l != null) ? v_edge_l : (v_edge_l = super.leftEdge().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst rightEdge() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_edge_r != null) ? v_edge_r : (v_edge_r = super.rightEdge().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst topEdge() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_edge_t != null) ? v_edge_t : (v_edge_t = super.topEdge().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst bottomEdge() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_edge_b != null) ? v_edge_b : (v_edge_b = super.bottomEdge().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Rect axisV() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_axis_v != null) ? v_axis_v : (v_axis_v = super.axisV().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Rect axisH() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_axis_h != null) ? v_axis_h : (v_axis_h = super.axisH().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Rect shrink(Vect shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrink(shrink); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst shrink(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrink(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst shrink(NumConst left, NumConst right, NumConst top, NumConst bottom) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrink(left, right, top, bottom).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst grow(NumConst left, NumConst right, NumConst top, NumConst bottom) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.grow(left, right, top, bottom).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst shrinkLeft(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkLeft(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst shrinkRight(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkRight(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst shrinkTop(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkTop(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst shrinkBottom(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkBottom(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst growLeft(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growLeft(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst growRight(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growRight(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst growUp(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growUp(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst growDown(double shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growDown(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst shrinkLeft(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkLeft(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst shrinkRight(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkRight(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst shrinkTop(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkTop(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst shrinkBottom(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrinkBottom(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst growLeft(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growLeft(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst growRight(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growRight(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst growUp(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growUp(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst growBottom(NumConst shrink) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.growDown(shrink).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst centerTo(VectConst point) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.centerTo(point).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst centerTo(RectConst parent) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.centerTo(parent).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst shrink(NumConst x, NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.shrink(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst grow(NumConst x, NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.grow(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,130 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.builders; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.logging.Log; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectProxy; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Utility for cutting rect into evenly sized cells. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class TiledRect extends RectProxy { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	final private int tilesY; | 
					 | 
				
			||||||
	final private int tilesX; | 
					 | 
				
			||||||
	final private Num perRow; | 
					 | 
				
			||||||
	final private Num perCol; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** Left top tile */ | 
					 | 
				
			||||||
	private Rect aTile; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public TiledRect(Rect source, int horizontal, int vertical) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		super(source); | 
					 | 
				
			||||||
		this.tilesX = horizontal; | 
					 | 
				
			||||||
		this.tilesY = vertical; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		this.perRow = height().div(vertical); | 
					 | 
				
			||||||
		this.perCol = width().div(horizontal); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		this.aTile = Rect.make(origin(), perCol, perRow); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set tile overlap. Applies only to tile, not span. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param overlap how far to overlap to neighbouring tiles on all sides | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setOverlap(double overlap) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		aTile = aTile.grow(overlap); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get a tile. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x x position | 
					 | 
				
			||||||
	 * @param y y position | 
					 | 
				
			||||||
	 * @return tile | 
					 | 
				
			||||||
	 * @throws IndexOutOfBoundsException when invalid index is specified. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public Rect tile(int x, int y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (x >= tilesX || x < 0) { | 
					 | 
				
			||||||
			throw new IndexOutOfBoundsException("X coordinate out fo range: " + x); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (y >= tilesY || y < 0) { | 
					 | 
				
			||||||
			throw new IndexOutOfBoundsException("Y coordinate out of range: " + y); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return aTile.move(perCol.mul(x), perRow.mul(y)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get a span (tile spanning across multiple cells) | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x x start position | 
					 | 
				
			||||||
	 * @param y y start position | 
					 | 
				
			||||||
	 * @param size_x horizontal size (columns) | 
					 | 
				
			||||||
	 * @param size_y vertical size (rows) | 
					 | 
				
			||||||
	 * @return tile the tile | 
					 | 
				
			||||||
	 * @throws IndexOutOfBoundsException when invalid index is specified. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public Rect span(int x, int y, int size_x, int size_y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		final int x_to = x + size_x - 1; | 
					 | 
				
			||||||
		final int y_to = y + size_y - 1; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (size_x <= 0 || size_y <= 0) { | 
					 | 
				
			||||||
			Log.w("Size must be > 0.", new IllegalAccessException()); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (x >= tilesX || x < 0 || x_to >= tilesX || x_to < 0) { | 
					 | 
				
			||||||
			Log.w("X coordinate(s) out of range.", new IllegalAccessException()); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (y >= tilesY || y < 0 || y_to >= tilesY || y_to < 0) { | 
					 | 
				
			||||||
			Log.w("Y coordinate(s) out of range.", new IllegalAccessException()); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		final Vect orig = origin().add(perCol.mul(x), perRow.mul(y)); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return Rect.make(orig, perCol.mul(size_x), perRow.mul(size_y)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get n-th column | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param n column index | 
					 | 
				
			||||||
	 * @return the column tile | 
					 | 
				
			||||||
	 * @throws IndexOutOfBoundsException when invalid index is specified. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public Rect column(int n) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return tile(n, 0); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Get n-th row | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param n row index | 
					 | 
				
			||||||
	 * @return the row rect | 
					 | 
				
			||||||
	 * @throws IndexOutOfBoundsException when invalid index is specified. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public Rect row(int n) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return tile(0, n); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,75 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.ConstraintCache; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.mutable.RectVar; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.proxy.RectAdapter; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * A rect cache. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * Values are held in a caching VectVar, and digest caching is enabled by | 
					 | 
				
			||||||
 * default. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class AbstractRectCache extends RectAdapter implements ConstraintCache<Rect> { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final RectVar cache = Rect.makeVar(); | 
					 | 
				
			||||||
	private boolean inited = false; | 
					 | 
				
			||||||
	private boolean cachingEnabled = true; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public AbstractRectCache() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		enableDigestCaching(true); // it changes only on poll
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected final Rect getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (!inited) poll(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return (cachingEnabled ? cache : getCacheSource()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void poll() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		inited = true; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// poll source
 | 
					 | 
				
			||||||
		final Rect source = getCacheSource(); | 
					 | 
				
			||||||
		source.markDigestDirty(); // poll cached
 | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// store source value
 | 
					 | 
				
			||||||
		cache.setTo(source); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		markDigestDirty(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		onConstraintChanged(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void enableCaching(boolean yes) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		cachingEnabled = yes; | 
					 | 
				
			||||||
		enableDigestCaching(yes); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final boolean isCachingEnabled() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return cachingEnabled; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,37 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.annot.DefaultImpl; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Rect cache implementation | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class RectCache extends AbstractRectCache { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Rect source; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectCache(Rect source) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.source = source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final Rect getCacheSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	@DefaultImpl | 
					 | 
				
			||||||
	public void onConstraintChanged() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,41 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class RectDigest { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public final double x; | 
					 | 
				
			||||||
	public final double y; | 
					 | 
				
			||||||
	public final double width; | 
					 | 
				
			||||||
	public final double height; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public final double left; | 
					 | 
				
			||||||
	public final double right; | 
					 | 
				
			||||||
	public final double top; | 
					 | 
				
			||||||
	public final double bottom; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectDigest(Rect rect) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.x = rect.origin().x(); | 
					 | 
				
			||||||
		this.y = rect.origin().y(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		this.width = rect.size().x(); | 
					 | 
				
			||||||
		this.height = rect.size().y(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		this.left = x; | 
					 | 
				
			||||||
		this.right = x + width; | 
					 | 
				
			||||||
		this.top = y; | 
					 | 
				
			||||||
		this.bottom = y + height; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public String toString() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return String | 
					 | 
				
			||||||
				.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,91 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.mutable; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Mutable rectangle; operations change it's state. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class RectMutable extends Rect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set to other rect's coordinates | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param rect other rect | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(Rect rect) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(rect.origin(), rect.size()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set to given size and position | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param origin new origin | 
					 | 
				
			||||||
	 * @param width new width | 
					 | 
				
			||||||
	 * @param height new height | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(Vect origin, double width, double height) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(origin, Vect.make(width, height)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set to given size and position | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x origin.x | 
					 | 
				
			||||||
	 * @param y origin.y | 
					 | 
				
			||||||
	 * @param width new width | 
					 | 
				
			||||||
	 * @param height new height | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(double x, double y, double width, double height) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(Vect.make(x, y), Vect.make(width, height)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set to given size and position | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param origin new origin | 
					 | 
				
			||||||
	 * @param size new size | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(Vect origin, Vect size) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setOrigin(origin); | 
					 | 
				
			||||||
		setSize(size); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set to zero | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void reset() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(Vect.ZERO, Vect.ZERO); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public abstract void setOrigin(double x, double y); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public void setOrigin(Vect origin) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setOrigin(origin.x(), origin.y()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public void setSize(Vect size) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setSize(size.x(), size.y()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public abstract void setSize(double x, double y); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,55 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.mutable; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class RectVar extends RectMutable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	final VectVar pos = Vect.makeVar(); | 
					 | 
				
			||||||
	final VectVar size = Vect.makeVar(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Create at given origin, with given size. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x | 
					 | 
				
			||||||
	 * @param y | 
					 | 
				
			||||||
	 * @param width | 
					 | 
				
			||||||
	 * @param height | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public RectVar(double x, double y, double width, double height) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.pos.setTo(x, y); | 
					 | 
				
			||||||
		this.size.setTo(width, height); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect origin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return pos; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect size() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return size; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setOrigin(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.pos.setTo(x, y); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setSize(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.size.setTo(x, y); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,16 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Pluggable rect bound | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface PluggableRectBound extends RectBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @param rect context to set | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	abstract void setRect(RectBound rect); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,58 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Rect proxy with abstract method for plugging in / generating rect | 
					 | 
				
			||||||
 * dynamically. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class RectAdapter extends Rect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	// adapters are needed in case the vect returned from source changes
 | 
					 | 
				
			||||||
	// (is replaced). This way, references to origin and rect will stay intact.
 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final VectAdapter originAdapter = new VectAdapter() { | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		@Override | 
					 | 
				
			||||||
		protected Vect getSource() | 
					 | 
				
			||||||
		{ | 
					 | 
				
			||||||
			return RectAdapter.this.getSource().origin(); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	}; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final VectAdapter sizeAdapter = new VectAdapter() { | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		@Override | 
					 | 
				
			||||||
		protected Vect getSource() | 
					 | 
				
			||||||
		{ | 
					 | 
				
			||||||
			return RectAdapter.this.getSource().size(); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	}; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return the proxied coord | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	protected abstract Rect getSource(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect origin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return originAdapter; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect size() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return sizeAdapter; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,18 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Rect constraint (ie. region) | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface RectBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return rect region | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	Rect getRect(); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,41 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Pluggable rect bound adapter | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class RectBoundAdapter extends RectAdapter implements PluggableRectBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private RectBound backing = null; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectBoundAdapter() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectBoundAdapter(RectBound bound) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		backing = bound; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setRect(RectBound rect) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.backing = rect; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Rect getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return backing.getRect(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,24 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class RectProxy extends RectAdapter { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Rect source; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectProxy(Rect source) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.source = source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected Rect getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,39 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.rect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Rect made of two {@link Vect}s | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class RectVectAdapter extends Rect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Vect origin; | 
					 | 
				
			||||||
	private final Vect size; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectVectAdapter(Vect origin, Vect size) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.origin = origin; | 
					 | 
				
			||||||
		this.size = size; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect origin() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return origin; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect size() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return size; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
									
										
											File diff suppressed because it is too large
											Load Diff
										
									
								
							
						@ -1,375 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.NumConst; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.rect.RectConst; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.caching.VectDigest; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Coordinate with immutable numeric values.<br> | 
					 | 
				
			||||||
 * This coordinate is guaranteed to never change, as opposed to view.<br> | 
					 | 
				
			||||||
 * It's arranged so that operations with constant arguments yield constant | 
					 | 
				
			||||||
 * results. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public final class VectConst extends Vect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final double x, y, z; | 
					 | 
				
			||||||
	// non-parametric operations are cached using lazy load.
 | 
					 | 
				
			||||||
	private NumConst v_size; | 
					 | 
				
			||||||
	private VectConst v_neg; | 
					 | 
				
			||||||
	private VectConst v_ceil; | 
					 | 
				
			||||||
	private VectConst v_floor; | 
					 | 
				
			||||||
	private VectConst v_round; | 
					 | 
				
			||||||
	private VectConst v_half; | 
					 | 
				
			||||||
	private VectConst v_abs; | 
					 | 
				
			||||||
	private NumConst v_xc; | 
					 | 
				
			||||||
	private NumConst v_yc; | 
					 | 
				
			||||||
	private NumConst v_zc; | 
					 | 
				
			||||||
	private VectDigest digest; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	VectConst(Vect other) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this(other.x(), other.y(), other.z()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	VectConst(double x, double y, double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.x = x; | 
					 | 
				
			||||||
		this.y = y; | 
					 | 
				
			||||||
		this.z = z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double x() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return x; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double y() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return y; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double z() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return X constraint | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final NumConst xn() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_xc != null) ? v_xc : (v_xc = Num.make(this.x)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return Y constraint | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final NumConst yn() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_yc != null) ? v_yc : (v_yc = Num.make(this.y)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return Z constraint | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final NumConst zn() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_zc != null) ? v_zc : (v_zc = Num.make(this.z)); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @deprecated it's useless to copy a constant | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	@Deprecated | 
					 | 
				
			||||||
	public VectConst freeze() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return this; // it's constant already
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectDigest digest() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (digest != null) ? digest : (digest = super.digest()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst abs() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_abs != null) ? v_abs : (v_abs = super.abs().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst add(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.add(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst add(double x, double y, double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.add(x, y, z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst half() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_half != null) ? v_half : (v_half = super.half().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst mul(double d) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(d).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst mul(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst mul(double x, double y, double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(x, y, z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst round() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_round != null) ? v_round : (v_round = super.round().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst floor() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_floor != null) ? v_floor : (v_floor = super.floor().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst ceil() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (v_ceil != null) return v_ceil; | 
					 | 
				
			||||||
		return v_ceil = super.ceil().freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst sub(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.sub(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst sub(double x, double y, double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.sub(x, y, z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst neg() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_neg != null) ? v_neg : (v_neg = super.neg().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst norm(double size) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.norm(size).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public NumConst size() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return (v_size != null) ? v_size : (v_size = super.size().freeze()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst withX(double x) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.withX(x).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst withY(double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.withY(y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public VectConst withZ(double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.withZ(z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst withX(NumConst x) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.withX(x).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst withY(NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.withY(y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst withZ(NumConst z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.withZ(z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst add(VectConst vec) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.add(vec).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst add(NumConst x, NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.add(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst add(NumConst x, NumConst y, NumConst z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.add(x, y, z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst mul(VectConst vec) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(vec).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst mul(NumConst d) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(d).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst mul(NumConst x, NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst mul(NumConst x, NumConst y, NumConst z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.mul(x, y, z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst sub(VectConst vec) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.sub(vec).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst sub(NumConst x, NumConst y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.sub(x, y).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst sub(NumConst x, NumConst y, NumConst z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.sub(x, y, z).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst norm(NumConst size) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.norm(size).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst dist(VectConst point) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.dist(point).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst midTo(VectConst point) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.midTo(point).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst vectTo(VectConst point) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.vectTo(point).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NumConst dot(VectConst vec) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.dot(vec).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectConst cross(VectConst vec) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.cross(vec).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public RectConst expand(double left, double right, double top, double bottom) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.expand(left, right, top, bottom).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public RectConst expand(NumConst left, NumConst right, NumConst top, NumConst bottom) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return super.expand(left, right, top, bottom).freeze(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,24 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class VectProxy extends VectAdapter { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Vect source; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectProxy(Vect source) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.source = source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected Vect getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,75 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.ConstraintCache; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.mutable.VectVar; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.proxy.VectAdapter; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * A vect cache. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 * <p> | 
					 | 
				
			||||||
 * Values are held in a caching VectVar, and digest caching is enabled by | 
					 | 
				
			||||||
 * default. | 
					 | 
				
			||||||
 * </p> | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class AbstractVectCache extends VectAdapter implements ConstraintCache<Vect> { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final VectVar cache = Vect.makeVar(); | 
					 | 
				
			||||||
	private boolean inited = false; | 
					 | 
				
			||||||
	private boolean cachingEnabled = true; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public AbstractVectCache() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		enableDigestCaching(true); // it changes only on poll
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected final Vect getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (!inited) markDigestDirty(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		return (cachingEnabled ? cache : getCacheSource()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void poll() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		inited = true; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// poll source
 | 
					 | 
				
			||||||
		final Vect source = getCacheSource(); | 
					 | 
				
			||||||
		source.markDigestDirty(); // poll cached
 | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		// store source value
 | 
					 | 
				
			||||||
		cache.setTo(source); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		markDigestDirty(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		onConstraintChanged(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final void enableCaching(boolean yes) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		cachingEnabled = yes; | 
					 | 
				
			||||||
		enableDigestCaching(yes); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public final boolean isCachingEnabled() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return cachingEnabled; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,37 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.annot.DefaultImpl; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Vect cache implementation | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class VectCache extends AbstractVectCache { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Vect source; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectCache(Vect source) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.source = source; | 
					 | 
				
			||||||
		enableDigestCaching(true); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public Vect getCacheSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return source; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	@DefaultImpl | 
					 | 
				
			||||||
	public void onConstraintChanged() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,27 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.caching; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class VectDigest { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public final double x; | 
					 | 
				
			||||||
	public final double y; | 
					 | 
				
			||||||
	public final double z; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectDigest(Vect vect) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.x = vect.x(); | 
					 | 
				
			||||||
		this.y = vect.y(); | 
					 | 
				
			||||||
		this.z = vect.z(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public String toString() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return String.format("Vect(%.1f, %.1f, %.1f)", x, y, z); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,80 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.mutable; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Mutable coord | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
abstract class VectMutable extends Vect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set all to zeros. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void reset() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(0, 0, 0); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set coordinates to match other coord. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param copied coord whose coordinates are used | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(Vect copied) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setTo(copied.x(), copied.y(), copied.z()); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set 2D coordinates.<br> | 
					 | 
				
			||||||
	 * Z is unchanged. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x x coordinate | 
					 | 
				
			||||||
	 * @param y y coordinate | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public void setTo(double x, double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		setX(x); | 
					 | 
				
			||||||
		setY(y); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set coordinates. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x x coordinate | 
					 | 
				
			||||||
	 * @param y y coordinate | 
					 | 
				
			||||||
	 * @param z z coordinate | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setTo(double x, double y, double z); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set X coordinate. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param x x coordinate | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setX(double x); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set Y coordinate. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param y y coordinate | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setY(double y); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Set Z coordinate. | 
					 | 
				
			||||||
	 *  | 
					 | 
				
			||||||
	 * @param z z coordinate | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public abstract void setZ(double z); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,78 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.mutable; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Mutable coordinate.<br> | 
					 | 
				
			||||||
 * All Vec methods (except copy) alter data values and return this instance. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class VectVar extends VectMutable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private double x, y, z; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @param x X coordinate | 
					 | 
				
			||||||
	 * @param y Y coordinate | 
					 | 
				
			||||||
	 * @param z Z coordinate | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public VectVar(double x, double y, double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		super(); | 
					 | 
				
			||||||
		this.x = x; | 
					 | 
				
			||||||
		this.y = y; | 
					 | 
				
			||||||
		this.z = z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double x() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return x; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double y() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return y; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double z() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setTo(double x, double y, double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.x = x; | 
					 | 
				
			||||||
		this.y = y; | 
					 | 
				
			||||||
		this.z = z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setX(double x) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.x = x; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setY(double y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.y = y; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setZ(double z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.z = z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,16 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Pluggable vector constraint | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface PluggableVectBound extends VectBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @param num bound to set | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	abstract void setVect(VectBound num); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,41 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Vect proxy with abstract method for plugging in / generating coordinates | 
					 | 
				
			||||||
 * dynamically. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public abstract class VectAdapter extends Vect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return the proxied coord | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	protected abstract Vect getSource(); | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double x() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return getSource().x(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double y() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return getSource().y(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double z() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return getSource().z(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,18 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Element holding a vector, used for constraint building. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public interface VectBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * @return the current vector. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	public Vect getVect(); | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,36 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class VectBoundAdapter extends VectAdapter implements PluggableVectBound { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private VectBound backing = null; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectBoundAdapter() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectBoundAdapter(VectBound bound) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		backing = bound; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void setVect(VectBound rect) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.backing = rect; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected Vect getSource() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return backing.getVect(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,57 +0,0 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.vect.proxy; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.proxy.NumBound; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Coord view composed of given {@link NumBound}s, using their current values. | 
					 | 
				
			||||||
 *  | 
					 | 
				
			||||||
 * @author Ondřej Hruška (MightyPork) | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
public class VectNumAdapter extends Vect { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final Num constrX; | 
					 | 
				
			||||||
	private final Num constrY; | 
					 | 
				
			||||||
	private final Num constrZ; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectNumAdapter(Num x, Num y, Num z) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.constrX = x; | 
					 | 
				
			||||||
		this.constrY = y; | 
					 | 
				
			||||||
		this.constrZ = z; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public VectNumAdapter(Num x, Num y) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.constrX = x; | 
					 | 
				
			||||||
		this.constrY = y; | 
					 | 
				
			||||||
		this.constrZ = Num.ZERO; | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double x() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return constrX.value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double y() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return constrY.value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public double z() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		return constrZ.value(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,4 +1,4 @@ | 
				
			|||||||
package mightypork.gamecore.eventbus.events; | 
					package mightypork.gamecore.util.math.timing; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
@ -1,12 +1,12 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.timing; | 
					package mightypork.gamecore.util.math.timing.animation; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import mightypork.gamecore.eventbus.events.Updateable; | 
					import mightypork.dynmath.num.Num; | 
				
			||||||
import mightypork.gamecore.util.annot.DefaultImpl; | 
					import mightypork.gamecore.util.annot.DefaultImpl; | 
				
			||||||
import mightypork.gamecore.util.math.Calc; | 
					import mightypork.gamecore.util.math.Calc; | 
				
			||||||
import mightypork.gamecore.util.math.Easing; | 
					import mightypork.gamecore.util.math.Easing; | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.Num; | 
					import mightypork.gamecore.util.math.timing.Pauseable; | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; | 
					import mightypork.gamecore.util.math.timing.Updateable; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public abstract class Animator extends Num implements Updateable, Pauseable { | 
					public abstract class Animator extends Num implements Updateable, Pauseable { | 
				
			||||||
@ -1,8 +1,7 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.timing; | 
					package mightypork.gamecore.util.math.timing.animation; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import mightypork.gamecore.util.math.Easing; | 
					import mightypork.gamecore.util.math.Easing; | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
@ -1,8 +1,7 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.timing; | 
					package mightypork.gamecore.util.math.timing.animation; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import mightypork.gamecore.util.math.Easing; | 
					import mightypork.gamecore.util.math.Easing; | 
				
			||||||
import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
@ -1,10 +1,11 @@ | 
				
			|||||||
package mightypork.gamecore.util.math.constraints.num.mutable; | 
					package mightypork.gamecore.util.math.timing.animation; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import mightypork.gamecore.eventbus.events.Updateable; | 
					import mightypork.dynmath.num.mutable.NumMutable; | 
				
			||||||
import mightypork.gamecore.util.math.Calc; | 
					import mightypork.gamecore.util.math.Calc; | 
				
			||||||
import mightypork.gamecore.util.math.Easing; | 
					import mightypork.gamecore.util.math.Easing; | 
				
			||||||
import mightypork.gamecore.util.math.timing.Pauseable; | 
					import mightypork.gamecore.util.math.timing.Pauseable; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.timing.Updateable; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
					Loading…
					
					
				
		Reference in new issue