Point3D class
Class Point3D represents a point in two or three-dimensional space.
The point coordinates are represented by x, y and z.
The Point class supports a wide variety of operations such as basic arithmetic operations,
transformation operations (like rotation and scaling), distance and angle calculations,
conversion to/from polar coordinates, and geometric operations related to lines, triangles,
circles, and polygons.
Constructors
- Point3D(num x, num y, num z)
-
Constructor for creating a new
Point. -
Point3D.fromList(List<
num> coords) -
Constructs a new
Pointfrom a list of numbers.factory - Point3D.fromSphericalCoordinates(num r, num theta, num phi)
-
Creates a 3D point and sets the coordinates of the point given spherical
coordinates
r,theta, andphi.factory
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- x ↔ num
-
The x-coordinate of the point.
getter/setter pair
- y ↔ num
-
The y-coordinate of the point.
getter/setter pair
- z ↔ num
-
The z-coordinate of the point.
getter/setter pair
Methods
-
angleBetween(
Point3D otherPoint) → Angle - Calculates the angle (in radians) between this point and another, considering the line between them as the hypotenuse of a right triangle.
-
bearingTo(
Point3D point) → Angle - Computes the bearing from this point to another point. The bearing is the angle (in degrees) between the line from this point to the other point and the line from this point to the eastward direction, measured clockwise from north.
-
distanceTo(
Point3D otherPoint) → double - Computes the Euclidean distance between this point and another.
-
distanceToCircle(
Point3D center, double radius) → double - Calculates the shortest distance from this point to a circle. If this point is inside the circle, the distance is 0.
-
distanceToLine(
Point3D linePoint1, Point3D linePoint2) → double - Calculates the shortest distance from this point to a line defined by two points.
-
distanceToPolyline(
List< Point3D> polyline) → double - Calculates the shortest distance from this point to a polyline, which is a list of points forming a broken line.
-
interpolate(
Point3D point1, Point3D point2) → Point3D -
Interpolates between two points, using this point as the ratio.
If
zisnullfor any of the points, the resulting point will be 2-dimensional. -
isCollinear(
Point3D a, Point3D b) → bool - Checks if this point is collinear with two other points.
-
isInsidePolygon(
List< Point3D> polygon, [double tolerance = 1e-10]) → bool - Checks if this point is inside a polygon or on its boundary. The polygon is represented by a list of points in counter-clockwise order. A tolerance value is used to handle floating point inaccuracies.
-
isOnLineSegment(
Point3D pointA, Point3D pointB, [double tolerance = 1e-10]) → bool - Checks if the point is on a line segment defined by two points. A tolerance value is used to handle floating point inaccuracies.
-
midpointTo(
Point3D otherPoint) → Point3D - Computes the midpoint between this point and another.
-
move(
num dx, num dy, num dz) → Point3D - Moves the point by a given delta along each axis.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reflect(
[Point3D? origin]) → Point3D -
Reflects the point through the given
origin. -
rotate(
Angle angle) → Point3D -
Rotates the point around the origin (0, 0, 0) by a given
angle(in radians). -
rotateBy(
num angle, [Point3D? origin]) → Point3D -
Rotates the point around a given
originby a specific `angle (in radians). -
scale(
num factor) → Point3D - Scales the point by a given factor.
-
slopeTo(
Point otherPoint) → double - Calculates the slope of the line formed by this point and another.
-
toList(
) → List< num> - Converts the point's coordinates to a list of numbers.
-
toString(
) → String -
A custom
toStringmethod for better readability.override -
toVector(
) → Vector3 -
Converts this
3DPointto a list of numbers, which can be used to represent it as a vector3. -
translate(
num dx, num dy, num dz) → Point3D -
Translates the point by the given amounts
dx,dy, anddz. -
triangleArea(
Point3D point1, Point3D point2) → double - Calculates the area of the triangle formed by this point and two other points.
Operators
-
operator *(
num scalar) → Point3D - Overrides the multiplication (*) operator.
-
operator +(
Point3D other) → Point3D - Overrides the addition (+) operator.
-
operator -(
Point3D other) → Point3D - Overrides the subtraction (-) operator.
-
operator /(
num scalar) → Point3D - Overrides the division (/) operator.
-
operator ==(
Object other) → bool -
Overloads the == (equality) operator.
override