Public Member Functions | Static Public Member Functions | Public Attributes | List of all members

2d point coordinates. More...

#include <dpoint2d.h>

Inheritance diagram for DPoint2d:
DVec2d

Public Member Functions

void Init (double x, double y)
 Initialize with given components. More...
 
void Zero ()
 Sets all components of a point or vector to zero. More...
 
void One ()
 Returns a point or vector with all components 1.0. More...
 
void Init (DPoint3dCR source)
 
void InitDisconnect ()
 Initialize a point with all coordinates as the disconnect value. More...
 
void SumOf (DPoint2dCR point1, DPoint2dCR point2)
 Compute the sum of two points or vectors. More...
 
void Add (DPoint2dCR vector)
 Add a vector to the instance. More...
 
void Subtract (DPoint2dCR vector)
 Subtract one vector from another in place. More...
 
void DifferenceOf (DPoint2dCR point1, DPoint2dCR point2)
 Return the difference of two points or vectors. More...
 
double NormalizedDifferenceOf (DPoint2dCR point1, DPoint2dCR point2)
 Sets pNormal to the unit vector in the direction of point1 point2. More...
 
void Scale (DPoint2dCR source, double s)
 Scale the instance coordinates from source. More...
 
void Scale (double s)
 Scale the instance coordinates (in place) More...
 
void Negate (DPoint2dCR vector)
 returns the negative of a vector. More...
 
double ScaleToLength (DPoint2dCR source, double length)
 Scales a vector to specified length. More...
 
double ScaleToLength (double length)
 Scales a vector to a specified length, and returns the prior length. More...
 
double Normalize ()
 normalizes pVector1 in place, and returns the original magnitude. More...
 
double Normalize (DPoint2dCR vector1)
 normalizes vector1, stores as instance, and returns the original magnitude. More...
 
void SumOf (DPoint2dCR vector1, double scale1, DPoint2dCR vector2, double scale2, DPoint2dCR vector3, double scale3)
 Adds three scaled points. More...
 
void SumOf (DPoint2dCR point, DPoint2dCR vector, double s)
 Adds an origin and a scaled vector. More...
 
void SumOf (DPoint2dCR origin, DPoint2dCR vector1, double scale1, DPoint2dCR vector2, double scale2)
 Adds an origin and two scaled vectors. More...
 
void SumOf (DPoint2dCR origin, DPoint2dCR vector1, double scale1, DPoint2dCR vector2, double scale2, DPoint2dCR vector3, double scale3)
 Adds an origin and three scaled vectors. More...
 
void Interpolate (DPoint2dCR point0, double s, DPoint2dCR point1)
 Compute the point at an interpolated (fractional) position between a start and end point. More...
 
void Rotate90 (DPoint2dCR vec)
 
void RotateCCW (DPoint2dCR vec, double radians)
 
void Swap (DPoint2dR other)
 Swap contents of instance, other. More...
 
double Magnitude () const
 Returns the magnitude (length) of a vector. More...
 
double MagnitudeSquared () const
 
double Distance (DPoint2dCR point1) const
 Returns the distance between 2 points. More...
 
double DistanceSquared (DPoint2dCR point2) const
 Return the squared distance between two points or vectors. More...
 
double CrossProduct (DPoint2dCR vector1) const
 Returns the (scalar) cross product of two vectors. More...
 
double CrossProductToPoints (DPoint2dCR target1, DPoint2dCR target2) const
 Returns the (scalar) cross product of two vectors. More...
 
double DotProduct (DPoint2dCR vector2) const
 Returns the (scalar) dot product of two vectors. More...
 
double DotProductToPoints (DPoint2dCR target1, DPoint2dCR target2) const
 Returns the (scalar) dot product of two vectors. More...
 
void SetComponent (double a, int index)
 Sets a single component of a point. More...
 
double GetComponent (int index) const
 Gets a single component of a point. More...
 
void GetComponents (double &xCoord, double &yCoord) const
 
void InitFromArray (const double *pXy)
 copy 2 components (xy) from a double array to the DPoint2d More...
 
double AngleTo (DPoint2dCR vector2) const
 Returns (signed, counterclockwise) angle between two vectors. More...
 
bool IsParallelTo (DPoint2dCR vector2) const
 Test if two vectors are parallel. More...
 
bool IsPerpendicularTo (DPoint2dCR vector2) const
 Test if two vectors are perpendicular. More...
 
bool IsEqual (DPoint2dCR vector2) const
 Test if two points or vectors are exactly equal. More...
 
bool IsEqual (DPoint2dCR vector2, double tolerance) const
 Test if the x and y components of two points or vectors are equal within tolerance. More...
 
double MaxAbs () const
 Finds the largest absolute value among the components of a point or vector. More...
 
bool IsDisconnect () const
 
bool IsConvexPair () const
 return true if the point has x, y, and x+1 all between 0 and 1 (inclusive). More...
 
bool AlmostEqual (DPoint2d const &dataB) const
 test if two points are equal. More...
 

Static Public Member Functions

static DPoint2d From (double ax, double ay)
 Returns a DPoint2d with 2 components (xy) from given components. More...
 
static DPoint2d FromZero ()
 Return a DPoint2d with xy = 0. More...
 
static DPoint2d FromOne ()
 Return a DPoint2d with xy = 1. More...
 
static DPoint2d From (DPoint3dCR source)
 Returns a DPoint2d from DPoint3d. More...
 
static DPoint2d FromScale (DPoint2d point, double scale)
 Returns a scalar multiple of a DPoint2d. More...
 
static DPoint2d FromSumOf (DPoint2dCR point0, double scale0, DPoint2dCR point1, double scale1)
 Returns a linear combination of points. More...
 
static DPoint2d FromSumOf (DPoint2dCR point0, double scale0, DPoint2dCR point1, double scale1, DPoint2dCR point2, double scale2)
 Returns a linear combination of points. More...
 
static DPoint2d FromSumOf (DPoint2dCR origin, DVec2dCR vector, double scaleFactor)
 Add scaled vector from origin. More...
 
static DPoint2d FromSumOf (DPoint2dCR origin, DVec2dCR vector0, double scaleFactor0, DVec2dCR vector1, double scaleFactor1)
 Add scaled vectors from an origin. More...
 
static DPoint2d FromSumOf (DPoint2dCR origin, DVec2dCR vector0, double scaleFactor0, DVec2dCR vector1, double scaleFactor1, DVec2dCR vector2, double scaleFactor2)
 Add scaled vectors from origin. More...
 
static DPoint2d FromInterpolate (DPoint2dCR point0, double fraction, DPoint2dCR point1)
 Returns an interpolated point. More...
 
static DPoint2d FromInterpolateBilinear (DPoint2dCR point00, DPoint2dCR point10, DPoint2dCR point01, DPoint2dCR point11, double u, double v)
 Returns a bilinear interpolation from corners (00)(10)(01)(11) More...
 

Public Attributes

double x
 x coordinate More...
 
double y
 y coordinate More...
 

Detailed Description

2d point coordinates.

x,y are public members.

Member Function Documentation

void Add ( DPoint2dCR  vector)

Add a vector to the instance.

Parameters
[in]vectorvector to add
bool AlmostEqual ( DPoint2d const &  dataB) const

test if two points are equal.

Uses library "small angle" as both absolute and relative tolerance. points are equal if squared distance between is less than (squared abstol) plus (squared relTol) * sum of cmponent squares

Parameters
[in]dataBsecond DPoint2d
Returns
true if within tolerance.
double AngleTo ( DPoint2dCR  vector2) const

Returns (signed, counterclockwise) angle between two vectors.

The angle is in radians. The angle range is from -pi to +pi; positive angles are counterclockwise, negative angles are clockwise.

Parameters
[in]vector2second vector
Returns
angle in radians
double CrossProduct ( DPoint2dCR  vector1) const

Returns the (scalar) cross product of two vectors.

Parameters
[in]vector1first vector
double CrossProductToPoints ( DPoint2dCR  target1,
DPoint2dCR  target2 
) const

Returns the (scalar) cross product of two vectors.

The vectors are computed from the Origin to Target1 and Target2.

Parameters
[in]target1target of first vector
[in]target2target of second vector
void DifferenceOf ( DPoint2dCR  point1,
DPoint2dCR  point2 
)

Return the difference of two points or vectors.

Parameters
[in]point1First point or vector.
[in]point2Second (subtracted) point or vector.
double Distance ( DPoint2dCR  point1) const

Returns the distance between 2 points.

Parameters
[in]point1second point
Returns
distance from point 0 to point 1
double DistanceSquared ( DPoint2dCR  point2) const

Return the squared distance between two points or vectors.

Parameters
[in]point2end point
Returns
squared distance between points
double DotProduct ( DPoint2dCR  vector2) const

Returns the (scalar) dot product of two vectors.

Parameters
[in]vector2second vector.
Returns
dot product of the two vectors
double DotProductToPoints ( DPoint2dCR  target1,
DPoint2dCR  target2 
) const

Returns the (scalar) dot product of two vectors.

The vectors are computed from the Origin to Target1 and Target2.

Parameters
[in]target1target of first vector
[in]target2target of second vector
static DPoint2d From ( double  ax,
double  ay 
)
static

Returns a DPoint2d with 2 components (xy) from given components.

Parameters
[in]axx coordinate
[in]ayy coordinate
static DPoint2d From ( DPoint3dCR  source)
static

Returns a DPoint2d from DPoint3d.

Parameters
[in]source
static DPoint2d FromInterpolate ( DPoint2dCR  point0,
double  fraction,
DPoint2dCR  point1 
)
static

Returns an interpolated point.

Parameters
[in]point0point at fraction 0
[in]fractionfraction from interpolation.
[in]point1point at fraction 1
static DPoint2d FromInterpolateBilinear ( DPoint2dCR  point00,
DPoint2dCR  point10,
DPoint2dCR  point01,
DPoint2dCR  point11,
double  u,
double  v 
)
static

Returns a bilinear interpolation from corners (00)(10)(01)(11)

Parameters
[in]point00point at (0,0)
[in]point10point at (1,0)
[in]point01point at (0,1)
[in]point11point at (1,1)
[in]uinterpolation fraction for edges (point00,point10) and (point01,point11)
[in]vinterpolation fraction for edges (point00,point10) and (point10,point11)
static DPoint2d FromOne ( )
static

Return a DPoint2d with xy = 1.

static DPoint2d FromScale ( DPoint2d  point,
double  scale 
)
static

Returns a scalar multiple of a DPoint2d.

Parameters
[in]pointinput point
[in]scalescale factor
static DPoint2d FromSumOf ( DPoint2dCR  point0,
double  scale0,
DPoint2dCR  point1,
double  scale1 
)
static

Returns a linear combination of points.

Parameters
[in]point0first point
[in]scale0first scale
[in]point1second point
[in]scale1second scale
static DPoint2d FromSumOf ( DPoint2dCR  point0,
double  scale0,
DPoint2dCR  point1,
double  scale1,
DPoint2dCR  point2,
double  scale2 
)
static

Returns a linear combination of points.

Parameters
[in]point0first point
[in]scale0first scale
[in]point1second point
[in]scale1second scale
[in]point2third point
[in]scale2third scale
static DPoint2d FromSumOf ( DPoint2dCR  origin,
DVec2dCR  vector,
double  scaleFactor 
)
static

Add scaled vector from origin.

Parameters
[in]originstart point
[in]vectorvector to scale.
[in]scaleFactormultiplier.
static DPoint2d FromSumOf ( DPoint2dCR  origin,
DVec2dCR  vector0,
double  scaleFactor0,
DVec2dCR  vector1,
double  scaleFactor1 
)
static

Add scaled vectors from an origin.

Parameters
[in]originstart point
[in]vector0vector to scale.
[in]scaleFactor0multiplier.
[in]vector1vector to scale.
[in]scaleFactor1multiplier.
static DPoint2d FromSumOf ( DPoint2dCR  origin,
DVec2dCR  vector0,
double  scaleFactor0,
DVec2dCR  vector1,
double  scaleFactor1,
DVec2dCR  vector2,
double  scaleFactor2 
)
static

Add scaled vectors from origin.

Parameters
[in]originstart point
[in]vector0vector to scale.
[in]scaleFactor0multiplier.
[in]vector1vector to scale.
[in]scaleFactor1multiplier.
[in]vector2vector to scale.
[in]scaleFactor2multiplier.
static DPoint2d FromZero ( )
static

Return a DPoint2d with xy = 0.

double GetComponent ( int  index) const

Gets a single component of a point.

If the index is out of range 0,1, it is interpreted cyclically.

Parameters
[in]index0=x, 1=y, others cyclic
Returns
specified component of the point or vector.
void GetComponents ( double &  xCoord,
double &  yCoord 
) const
Parameters
[out]xCoordx component
[out]yCoordy component
void Init ( double  x,
double  y 
)

Initialize with given components.

Parameters
[in]xx component
[in]yy component
void Init ( DPoint3dCR  source)
Parameters
[in]sourcex, y components
void InitDisconnect ( )

Initialize a point with all coordinates as the disconnect value.

void InitFromArray ( const double *  pXy)

copy 2 components (xy) from a double array to the DPoint2d

Parameters
[in]pXyx, y components
void Interpolate ( DPoint2dCR  point0,
double  s,
DPoint2dCR  point1 
)

Compute the point at an interpolated (fractional) position between a start and end point.

Parameters
[in]point0start point (at parameter s=0)
[in]sinterpolation parameter
[in]point1end point (at parameter s=1)
bool IsConvexPair ( ) const

return true if the point has x, y, and x+1 all between 0 and 1 (inclusive).

bool IsDisconnect ( ) const
Returns
true if the point has coordinates which indicate it is a disconnect (separator) ponit.
bool IsEqual ( DPoint2dCR  vector2) const

Test if two points or vectors are exactly equal.

Parameters
[in]vector2Second point or vector
Returns
true if the points are identical. (DPoint2dCR, double)
bool IsEqual ( DPoint2dCR  vector2,
double  tolerance 
) const

Test if the x and y components of two points or vectors are equal within tolerance.

Tests are done independently using the absolute value of each component differences (i.e. not the magnitude or sum of squared differences)

Parameters
[in]vector2second point or vector
[in]tolerancetolerance
Returns
true if all components are within given tolerance of each other.
bool IsParallelTo ( DPoint2dCR  vector2) const

Test if two vectors are parallel.

Parameters
[in]vector2Second vector
Returns
true if vectors are (nearly) parallel.
bool IsPerpendicularTo ( DPoint2dCR  vector2) const

Test if two vectors are perpendicular.

Parameters
[in]vector2Second vector
Returns
true if vectors are (nearly) parallel.
double Magnitude ( ) const

Returns the magnitude (length) of a vector.

Returns
Length of the vector.
double MagnitudeSquared ( ) const
Returns
squared magnitude of the vector
double MaxAbs ( ) const

Finds the largest absolute value among the components of a point or vector.

Returns
largest absolute value among point coordinates.
void Negate ( DPoint2dCR  vector)

returns the negative of a vector.

Parameters
[in]vectorinput
double Normalize ( )

normalizes pVector1 in place, and returns the original magnitude.

If the original magnitude is 0 the vector is left unchanged.

Returns
original length
double Normalize ( DPoint2dCR  vector1)

normalizes vector1, stores as instance, and returns the original magnitude.

If the original magnitude is 0 the vector is copied.

Returns
original length
double NormalizedDifferenceOf ( DPoint2dCR  point1,
DPoint2dCR  point2 
)

Sets pNormal to the unit vector in the direction of point1 point2.

Parameters
[in]point1point 1
[in]point2point 2
Returns
double distance between input points
void One ( )

Returns a point or vector with all components 1.0.

void Rotate90 ( DPoint2dCR  vec)
Parameters
[in]vecoriginal vector
void RotateCCW ( DPoint2dCR  vec,
double  radians 
)
Parameters
[in]vecoriginal vector
[in]radiansrotation angle
Remarks
Note that this is a counterclockwise rotation. The "rotate" method in prior api was clockwise.
void Scale ( DPoint2dCR  source,
double  s 
)

Scale the instance coordinates from source.

Parameters
[in]sourceinput point
[in]sscale factor
void Scale ( double  s)

Scale the instance coordinates (in place)

Parameters
[in]sscale factor
double ScaleToLength ( DPoint2dCR  source,
double  length 
)

Scales a vector to specified length.

If the input vector length is 0, the output vector is a zero vector and the returned length is 0.

Parameters
[in]sourceThe original vector.
[in]lengthThe requested length.
Returns
The length prior to scaling.
double ScaleToLength ( double  length)

Scales a vector to a specified length, and returns the prior length.

If the input vector length is 0, the output vector is a zero vector and the returned length is 0.

Parameters
[in]lengthThe requested length
Returns
The length prior to scaling.
void SetComponent ( double  a,
int  index 
)

Sets a single component of a point.

If the index is out of range 0,1, it is interpreted cyclically.

Parameters
[in]avalue for component
[in]index0=x, 1=y, others cyclic
void Subtract ( DPoint2dCR  vector)

Subtract one vector from another in place.

Parameters
[in]vectorvector to subtract
void SumOf ( DPoint2dCR  point1,
DPoint2dCR  point2 
)

Compute the sum of two points or vectors.

Parameters
[in]point1First point or vector
[in]point2Second point or vector
void SumOf ( DPoint2dCR  vector1,
double  scale1,
DPoint2dCR  vector2,
double  scale2,
DPoint2dCR  vector3,
double  scale3 
)

Adds three scaled points.

Parameters
[in]vector1direction vector
[in]scale1scale factor
[in]vector2direction vector
[in]scale2scale factor
[in]vector3direction vector
[in]scale3scale factor
void SumOf ( DPoint2dCR  point,
DPoint2dCR  vector,
double  s 
)

Adds an origin and a scaled vector.

Parameters
[in]pointorigin.
[in]vectordirection vector
[in]sscale factor
void SumOf ( DPoint2dCR  origin,
DPoint2dCR  vector1,
double  scale1,
DPoint2dCR  vector2,
double  scale2 
)

Adds an origin and two scaled vectors.

Parameters
[in]originorigin.
[in]vector1direction vector
[in]scale1scale factor
[in]vector2direction vector
[in]scale2scale factor
void SumOf ( DPoint2dCR  origin,
DPoint2dCR  vector1,
double  scale1,
DPoint2dCR  vector2,
double  scale2,
DPoint2dCR  vector3,
double  scale3 
)

Adds an origin and three scaled vectors.

Parameters
[in]originorigin.
[in]vector1direction vector
[in]scale1scale factor
[in]vector2direction vector
[in]scale2scale factor
[in]vector3direction vector
[in]scale3scale factor
void Swap ( DPoint2dR  other)

Swap contents of instance, other.

Parameters
[in,out]othersecond point.
void Zero ( )

Sets all components of a point or vector to zero.

Referenced by GeometryId::GeometryId().

Member Data Documentation

double x

x coordinate

Referenced by GeometryId::GetParameter(), and GeometryId::SetParameter().

double y

y coordinate


The documentation for this struct was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.