/** * Initializes the members with default values. */ public AbstractVisual2D(Object position, Object rotation, Object size) { this.size = size!=null? size: new Vector2Double(1.0); this.rotation = rotation!=null? rotation: Vector3Double.ZERO.copy(); this.position = position!=null? position: Vector2Double.ZERO.copy(); }
/** * Create a vector2 from this and another vector. * @param sec The second vector. */ public IVector2 createVector2(IVector1 sec) { return new Vector2Double(this.getAsDouble(), sec.getAsDouble()); }
/** * Create a vector2 from this and another vector. * @param sec The second vector. */ public IVector2 createVector2(IVector1 sec) { return new Vector2Double(this.getAsInteger(), sec.getAsInteger()); }
/** * Sets the position of the viewport. */ public void setPosition(IVector2 pos) { position_ = pos; IVector2 pixSize = getPixelSize(); pixPosition_ = position_.copy().divide(pixSize); pixPosition_ = (new Vector2Double(new Vector2Int(pixPosition_))).multiply(pixSize); }
/** * Set the area size. * @param areasize The area size. */ public void setAreaSize(IVector2 areasize) { synchronized(monitor) { this.areasize = areasize==null? null: new Vector2Int(areasize.getXAsInteger(), areasize.getYAsInteger()); } }
public static double getDistance(Object v1, Object v2) { double ret; if(v1 instanceof IVector3) { ret = ((IVector3)v1).getDistance((IVector3)v2).getAsDouble(); } else { ret = ((IVector2)v1).getDistance((IVector2)v2).getAsDouble(); } return ret; } }
/** * */ public static boolean isGreater(IVector2 pos, IVector2 pos1, IVector2 pos2) { return pos.getDistance(pos1).greater(pos.getDistance(pos2)); } }
/** * Create a vector2 from this and another vector. * @param sec The second vector. */ public IVector2 createVector2(IVector1 sec) { return new Vector2Double(this.getAsLong(), sec.getAsLong()); }
/** Makes a copy of the vector without using the complex clone interface. * * @return copy of the vector */ public synchronized IVector2 copy() { return new SynchronizedVector2Wrapper(vector_.copy()); }
/** * Set the area size. * @param areasize The area size. */ public void setAreaSize(IVector3 areasize) { synchronized(monitor) { this.areasize = areasize==null? null: new Vector3Int(areasize.getXAsInteger(), areasize.getYAsInteger(), areasize.getZAsInteger()); } }
public IVector1 multiply(IVector1 vector) { x_ *= vector.getAsDouble(); return this; }
/** Subtracts a scalar to each component of this vector. * * @param scalar scalar value as double * @return a reference to the called vector (NOT a copy) */ public synchronized IVector2 subtract(double scalar) { vector_.subtract(scalar); return this; }
/** * Returns true if the x-axis is inverted (right-left instead of * left-right). * * @return true, if the x-axis is inverted */ public boolean getInvertX() { return inversionFlag_.getXAsInteger() > 0; }
/** Returns the direction (theta) of the vector as double. * * @return vector direction as double */ public synchronized double getDirectionAsDouble() { return vector_.getDirectionAsDouble(); }
/** Returns the distance to another vector. * * @param vector other vector * @return distance */ public synchronized IVector1 getDistance(IVector2 vector) { return vector_.getDistance(vector); }
/** * Sets the size (scale) of the visual to a fixed size. * @param size fixed size */ public void setSize(IVector3 size) { this.size = size.copy(); }
/** Assigns this vector the values of another vector. * * @param vector the other vector * @return a reference to the called vector (NOT a copy) */ public synchronized IVector2 assign(IVector2 vector) { vector_.assign(vector); return this; }
/** Applies a modulo vector. The modulus will be added first so that * values in the interval (-modulus, 0) will wrap over into the positive range. * * @param modulus modulus * @return a reference to the called vector (NOT a copy) */ public synchronized IVector2 mod(IVector2 modulus) { vector_.mod(modulus); return this; }
/** Negates the vector by negating its components. * * @return a reference to the called vector (NOT a copy) */ public synchronized IVector2 negate() { vector_.negate(); return this; }
/** Subtracts a scalar to each component of this vector. * * @param scalar scalar value * @return a reference to the called vector (NOT a copy) */ public synchronized IVector2 subtract(IVector1 scalar) { vector_.subtract(scalar); return this; }