@Override // from IRay2 public boolean intersects (IVector pt) { if (Math.abs(direction.x) > Math.abs(direction.y)) { float t = (pt.x() - origin.x) / direction.x; return t >= 0f && origin.y + t*direction.y == pt.y(); } else { float t = (pt.y() - origin.y) / direction.y; return t >= 0f && origin.x + t*direction.x == pt.x(); } }
@Override // from interface IVector public float angleBetween (IVector other) { float cos = dot(other) / (length() * other.length()); return cos >= 1f ? 0f : FloatMath.acos(cos); }
@Override // from IRay2 public Vector getNearestPoint (IVector point, Vector result) { if (result == null) { result = new Vector(); } float r = point.subtract(origin).dot(direction); result.set(origin.add(direction.scale(r))); return result; }
@Override // from interface IVector public float angleBetween (IVector other) { float cos = dot(other) / (length() * other.length()); return cos >= 1f ? 0f : FloatMath.acos(cos); }
@Override // from IRay2 public Vector getNearestPoint (IVector point, Vector result) { if (result == null) { result = new Vector(); } float r = point.subtract(origin).dot(direction); result.set(origin.add(direction.scale(r))); return result; }
@Override // from IRay2 public boolean intersects (IVector pt) { if (Math.abs(direction.x) > Math.abs(direction.y)) { float t = (pt.x() - origin.x) / direction.x; return t >= 0f && origin.y + t*direction.y == pt.y(); } else { float t = (pt.y() - origin.y) / direction.y; return t >= 0f && origin.x + t*direction.x == pt.x(); } }
/** * Returns the parameter of the ray when it intersects the supplied point, or * {@link Float#MAX_VALUE} if there is no such intersection. */ protected float getIntersection (IVector pt) { if (Math.abs(direction.x) > Math.abs(direction.y)) { float t = (pt.x() - origin.x) / direction.x; return (t >= 0f && origin.y + t*direction.y == pt.y()) ? t : Float.MAX_VALUE; } else { float t = (pt.y() - origin.y) / direction.y; return (t >= 0f && origin.x + t*direction.x == pt.x()) ? t : Float.MAX_VALUE; } } }
/** * Returns the parameter of the ray when it intersects the supplied point, or * {@link Float#MAX_VALUE} if there is no such intersection. */ protected float getIntersection (IVector pt) { if (Math.abs(direction.x) > Math.abs(direction.y)) { float t = (pt.x() - origin.x) / direction.x; return (t >= 0f && origin.y + t*direction.y == pt.y()) ? t : Float.MAX_VALUE; } else { float t = (pt.y() - origin.y) / direction.y; return (t >= 0f && origin.x + t*direction.x == pt.x()) ? t : Float.MAX_VALUE; } } }
/** * Sets this to a matrix that first scales, then rotates, then translates. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToTransform (IVector translation, float rotation, IVector scale) { float sx = scale.x(), sy = scale.y(); return setToRotation(rotation).set(m00 * sx, m10 * sy, translation.x(), m01 * sx, m11 * sy, translation.y(), 0f, 0f, 1f); }
/** * Sets this to a matrix that first scales, then rotates, then translates. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToTransform (IVector translation, float rotation, IVector scale) { float sx = scale.x(), sy = scale.y(); return setToRotation(rotation).set(m00 * sx, m10 * sy, translation.x(), m01 * sx, m11 * sy, translation.y(), 0f, 0f, 1f); }