Package drawit
Class DoubleVector
java.lang.Object
drawit.DoubleVector
public class DoubleVector extends Object
-
Constructor Summary
Constructors Constructor Description DoubleVector(double x, double y)
-
Method Summary
Modifier and Type Method Description double
asAngle()
Returns the angle from positive X to this vector, in radians.double
crossProduct(DoubleVector other)
Returns the cross product of this vector and the given vector.double
dotProduct(DoubleVector other)
Returns the dot product of this vector and the given vector.double
getSize()
double
getX()
double
getY()
DoubleVector
plus(DoubleVector other)
DoubleVector
scale(double d)
Returns aDoubleVector
object whose coordinates are obtained by multiplying this vector's coordinates by the given scale factor.
-
Constructor Details
-
DoubleVector
public DoubleVector(double x, double y)
-
-
Method Details
-
getX
public double getX() -
getY
public double getY() -
scale
Returns aDoubleVector
object whose coordinates are obtained by multiplying this vector's coordinates by the given scale factor. -
plus
-
getSize
public double getSize() -
dotProduct
Returns the dot product of this vector and the given vector.- Postconditions:
result == this.getX() * other.getX() + this.getY() * other.getY()
-
crossProduct
Returns the cross product of this vector and the given vector.- Postconditions:
result == this.getX() * other.getY() - this.getY() * other.getX()
-
asAngle
public double asAngle()Returns the angle from positive X to this vector, in radians. The angle from positive X to positive Y isMath.PI / 2
; the angle from positive X to negative Y is-Math.PI / 2
.Implementation Hint: See
Math.atan2(double, double)
.
-