Class Point_2
java.lang.Object
Jcg.geometry.Point_2
- All Implemented Interfaces:
Comparable<Point_>,Point_
A class for representing a 2D point with real coordinates.
- Author:
- Luca Castelli Aleardi (Ecole Polytechnique, 2010-2022)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbarycenter(Point_[] points) Set the current point as the barycenter of an array of pointsintcompareCartesian(Point_ o, int i) Compare the i-th coordinate of two pointsintCompare two points (lexicographic order on coordinates)intReturn the dimension of the spacebooleangetCartesian(int i) return the i-th cartesian coordinate of the pointintgetIndex()Return the indexgetX()getY()inthashCode()voidlinearCombination(Point_[] points, Number[] coefficients) Set the current point a linear combination of an array of points.static Point_2linearCombination(Point_2[] points, Number[] coefficients) Return a new point defined by the linear combination of the input points, with respect to the given input coefficientsstatic Point_2Return the vector (p-q), where q is the current pointvoidsetCartesian(int i, Number x) set the i-th cartesian coordinatevoidsetIndex(int index) Set the indexvoidset the coordinates of the originvoidvoidReturn the square distance ||p-q||^2, where q is the current pointtoString()Return a string (representation of the point)voidTranslate the current point according to a vector v
-
Field Details
-
index
public int indexan integer useful for indexing this point -
x
Geometric coordinates of the point -
y
Geometric coordinates of the point
-
-
Constructor Details
-
Point_2
public Point_2() -
Point_2
-
Point_2
-
Point_2
Initialize a 2D point having real coordinates (0.0, 0.0).
-
-
Method Details
-
barycenter
Set the current point as the barycenter of an array of points- Specified by:
barycenterin interfacePoint_
-
linearCombination
Description copied from interface:Point_Set the current point a linear combination of an array of points. Coefficients must sum to 1- Specified by:
linearCombinationin interfacePoint_
-
linearCombination
-
midPoint
-
getIndex
public int getIndex()Return the index -
getX
-
getY
-
setIndex
public void setIndex(int index) Set the index -
setX
-
setY
-
translateOf
Description copied from interface:Point_Translate the current point according to a vector v- Specified by:
translateOfin interfacePoint_
-
equals
-
hashCode
-
distanceFrom
-
squareDistance
Description copied from interface:Point_Return the square distance ||p-q||^2, where q is the current point- Specified by:
squareDistancein interfacePoint_
-
toString
-
dimension
-
getCartesian
Description copied from interface:Point_return the i-th cartesian coordinate of the point- Specified by:
getCartesianin interfacePoint_
-
setCartesian
Description copied from interface:Point_set the i-th cartesian coordinate- Specified by:
setCartesianin interfacePoint_
-
setOrigin
-
minus
-
sum
-
compareTo
Compare two points (lexicographic order on coordinates)- Specified by:
compareToin interfaceComparable<Point_>- Parameters:
o- the point to compare
-
compareCartesian
Compare the i-th coordinate of two points- Specified by:
compareCartesianin interfacePoint_- Parameters:
o- the point to comparei- the i-th coordinate to compare- Returns:
- the result is -1 if first point is smaller then point o, return 1 is first point is greater then o, and 0 otherwise
-