java.lang.Object
uk.ac.leeds.ccg.v3d.core.V3D_Object
uk.ac.leeds.ccg.v3d.geometry.V3D_Vector
- All Implemented Interfaces:
java.io.Serializable
public class V3D_Vector extends V3D_Object
V3D_Vector
- Version:
- 1.0
- Author:
- Andy Turner
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description V3D_Vector(V3D_Environment e, ch.obermuhlner.math.big.BigRational dx, ch.obermuhlner.math.big.BigRational dy, ch.obermuhlner.math.big.BigRational dz)V3D_Vector(V3D_Point p)Creates a vector from the origin topV3D_Vector(V3D_Point p, V3D_Point q)Creates a vector fromptoq -
Method Summary
Modifier and Type Method Description V3D_Vectoradd(V3D_Vector v)booleanequals(java.lang.Object o)V3D_VectorgetCrossProduct(V3D_Vector v)Calculate and return the cross product.ch.obermuhlner.math.big.BigRationalgetDotProduct(V3D_Vector v)Calculate and return the dot product.java.math.BigDecimalgetMagnitude(int scale, java.math.RoundingMode rm)Get the magnitude of the vector at the given scale.V3D_VectorgetUnitVector(int scale, java.math.RoundingMode rm)Scales the vector by the magnitude so that it has length 1inthashCode()protected java.math.BigDecimalinitMagnitude(int scale, java.math.RoundingMode rm)booleanisOrthogonal(V3D_Vector v)Test if this is orthogonal tov.booleanisParallel(V3D_Vector v)Test if this is parallel tov.booleanisZeroVector()V3D_Vectormultiply(ch.obermuhlner.math.big.BigRational s)V3D_Vectorsubtract(V3D_Vector v)java.lang.StringtoString()
-
Field Details
-
Constructor Details
-
V3D_Vector
public V3D_Vector(V3D_Environment e, ch.obermuhlner.math.big.BigRational dx, ch.obermuhlner.math.big.BigRational dy, ch.obermuhlner.math.big.BigRational dz) -
V3D_Vector
Creates a vector from the origin top- Parameters:
p- the point to which the vector starting at the origin goes.
-
V3D_Vector
Creates a vector fromptoq- Parameters:
p- the point where the vector starts.q- the point where the vector ends.
-
-
Method Details
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
isZeroVector
public boolean isZeroVector()- Returns:
trueifthis.equals(e.zeroVector)
-
multiply
- Parameters:
s- The scalar value to multiply this by.- Returns:
- Scaled vector.
-
add
- Parameters:
v- The vector to add.- Returns:
- A new vector which is this add
v.
-
subtract
- Parameters:
v- The vector to subtract.- Returns:
- A new vector which is this subtract
v.
-
getDotProduct
Calculate and return the dot product.- Parameters:
v- V3D_Vector- Returns:
- dot product
-
isOrthogonal
Test if this is orthogonal tov.- Parameters:
v- The- Returns:
trueif this andvare orthogonal.
-
getMagnitude
public java.math.BigDecimal getMagnitude(int scale, java.math.RoundingMode rm)Get the magnitude of the vector at the given scale.- Parameters:
scale- The scale for the precision of the result.rm- The RoundingMode for any rounding.- Returns:
magnitudeinitialised withscaleandrm.
-
initMagnitude
protected java.math.BigDecimal initMagnitude(int scale, java.math.RoundingMode rm)- Parameters:
scale- The scale for the precision of the result.rm- The RoundingMode for any rounding.- Returns:
magnitudeinitialised withscaleandrm.
-
isParallel
Test if this is parallel tov.- Parameters:
v- The vector to test if it is parallel to this.- Returns:
trueif this andvare orthogonal.
-
getCrossProduct
Calculate and return the cross product. Treat this as the first vector andvas the second vector. The resulting vector is in the direction given by the right hand rule.- Parameters:
v- V3D_Vector- Returns:
- V3D_Vector
-
getUnitVector
Scales the vector by the magnitude so that it has length 1- Parameters:
scale- The scale for the precision of the result.rm- The RoundingMode for any rounding.- Returns:
- this scaled by the magnitude.
-