Vector2d p2 = new Vector2d(distance, targetPos.getY()); Vector2d v1 = p2.sub(p1); Vector2d v2 = Vector2d.UNIT_X.mul(distance);
public Vector2d transform(double x, double y) { return new Vector2d( m00 * x + m01 * y, m10 * x + m11 * y); }
@Override public Vector2d toDouble() { return new Vector2d(x, y); }
@Override public Vector2d clone() { return new Vector2d(this); }
@Override public Vector2d toDouble() { return new Vector2d(x, y); }
function MyCustomShape() { var obj = Object.create(DisplayObject.prototype); // more construction obj.velocity = new Vector2d(); return obj; }
public Vector2d toVector2(boolean useZ) { return new Vector2d(x, useZ ? z : y); }
@Override public Vector2d round() { return new Vector2d(Math.round(x), Math.round(y)); }
@Override public Vector2d abs() { return new Vector2d(Math.abs(x), Math.abs(y)); }
public Vector2d project(double x, double y) { final double lengthSquared = x * x + y * y; if (Math.abs(lengthSquared) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot project onto the zero vector"); } final double a = dot(x, y) / lengthSquared; return new Vector2d(a * x, a * y); }
@Override public Vector2d normalize() { final double length = length(); if (Math.abs(length) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot normalize the zero vector"); } return new Vector2d(x / length, y / length); }
function CustomShape() { var obj = new DisplayObject(); obj.velocity = new Vector2d(); return obj; }
@Override public Vector2d normalize() { final double length = length(); if (Math.abs(length) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot normalize the zero vector"); } return new Vector2d(x / length, y / length); }
/** * Returns a unit vector pointing in the same direction as this complex on the complex plane. * * @return The vector representing the direction this complex is pointing to */ public Vector2d getDirection() { return new Vector2d(x, y).normalize(); }
public static Vector2d deserialize2d(JsonElement element) { return new Vector2d( element.getAsJsonObject().get("x").getAsDouble(), element.getAsJsonObject().get("y").getAsDouble() ); }
public static Vector2d deserialize2d(JsonElement element) { return new Vector2d( element.getAsJsonObject().get("x").getAsDouble(), element.getAsJsonObject().get("y").getAsDouble() ); }
/** * Gets the direction vector of a certain angle in radians. * * @param angle in radians * @return the direction vector */ public static Vector2d createDirectionRad(double angle) { return new Vector2d(TrigMath.cos(angle), TrigMath.sin(angle)); } }
@Override public Vector2d getColumn(int col) { return new Vector2d(get(0, col), get(1, col)); }
/** * Gets the direction vector of a certain angle in radians. * * @param angle in radians * @return the direction vector */ public static Vector2d createDirectionRad(double angle) { return new Vector2d(TrigMath.cos(angle), TrigMath.sin(angle)); } }
@Override public Vector2d getColumn(int col) { return new Vector2d(get(0, col), get(1, col)); }