Package math
Class Point
java.lang.Object
math.Point
public class Point
extends java.lang.Object
- Author:
- GBEMIRO
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Point()ICreates a Point object at the origin of 3D space.Point(double x)Initializes a 1D Point objectPoint(double x, double y)Initializes a 2D Point objectPoint(double x, double y, double z)Initializes a 2D Point objectPoint(Point point)Creates a new Point object similar to this one but not referring to the same object -
Method Summary
Modifier and Type Method Description doublecalcDistanceTo(Point pt)doublefindXYGrad(Point pt)doublefindXZGrad(Point pt)doublefindYZGrad(Point pt)SimplePointgetUtilPoint()Converts objects of this class to the normal Point object.static SimplePointgetUtilPoint(Point point)Converts objects of this class to the normal Point object.doublegetX()doublegetY()doublegetZ()booleanisCollinearWith(Point p1, Point p2)booleanliesBetween(Point p1, Point p2)static voidmain(java.lang.String[] args)static PointmidPoint(Point p1, Point p2)voidsetX(double x)voidsetY(double y)voidsetZ(double z)java.lang.StringtoString()
-
Field Details
-
Constructor Details
-
Point
public Point()ICreates a Point object at the origin of 3D space. -
Point
public Point(double x)Initializes a 1D Point object- Parameters:
x- the x coordinate of the Point object
-
Point
public Point(double x, double y)Initializes a 2D Point object- Parameters:
x- the x coordinate of the Point objecty- the y coordinate of the Point object
-
Point
public Point(double x, double y, double z)Initializes a 2D Point object- Parameters:
x- the x coordinate of the Point objecty- the y coordinate of the Point objectz- the z coordinate of the Point object
-
Point
Creates a new Point object similar to this one but not referring to the same object- Parameters:
point- The point to mutate
-
-
Method Details
-
setX
public void setX(double x)- Parameters:
x- sets x the x coordinate of the Point object
-
getX
public double getX()- Returns:
- x the x coordinate of the Point object
-
setY
public void setY(double y)- Parameters:
y- x the y coordinate of the Point object
-
getY
public double getY()- Returns:
- x the y coordinate of the Point object
-
setZ
public void setZ(double z)- Parameters:
z- sets the z coordinate of the Point object
-
getZ
public double getZ()- Returns:
- the z coordinate of the Point object
-
calcDistanceTo
- Parameters:
pt- the Point object whose distance to this Point object is required- Returns:
- the distance between this Point object and Point pt
-
findXYGrad
- Parameters:
pt- the point between which an imaginary line runs- Returns:
- the gradient of the projection of the line joining these points on the XY plane
-
findXZGrad
- Parameters:
pt- the point between which an imaginary line runs- Returns:
- the gradient of the projection of the line joining these points on the XZ plane
-
findYZGrad
- Parameters:
pt- the point between which an imaginary line runs- Returns:
- the gradient of the projection of the line joining these points on the YZ plane
-
getUtilPoint
Converts objects of this class to the normal Point object.- Returns:
- a java.awt.Point object from this Point object
-
getUtilPoint
Converts objects of this class to the normal Point object.- Parameters:
point-- Returns:
- a java.awt.Point object from an object of this class.
-
midPoint
- Parameters:
p1- The first Point object.p2- The second Point object.- Returns:
- The Point object that contains the coordinates of the midpoint of the line joining p1 and p2
-
isCollinearWith
- Parameters:
p1-p2-- Returns:
- true if the 2 points and this one lie on the same straight line.
-
liesBetween
- Parameters:
p1-p2-- Returns:
- true if this Point object lies on the same straight line with p1 and p2 and it lies in between them.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-