3ds Max C++ API Reference
Loading...
Searching...
No Matches
dpoint2.h File Reference
#include "GeomExport.h"
#include "point2.h"
#include <cassert>
#include <iosfwd>

Classes

class  DPoint2
 Description: This class describes a 2D point using double precision x and y coordinates. More...
 
class  DRay2
 This class describes a vector in space using an origin point p, and a unit direction vector in double precision. More...
 

Functions

double Length (const DPoint2 &p)
 Returns the 'Length' of the point.
 
constexpr double LengthSquared (const DPoint2 &p)
 The 'Length' squared of this point.
 
int MaxComponent (const DPoint2 &p)
 Returns the component with the maximum absolute value.
 
int MinComponent (const DPoint2 &p)
 Returns the component with the minimum absolute value.
 
DPoint2 Normalize (const DPoint2 &p)
 Returns a unit vector.
 
constexpr double DotProd (const DPoint2 &a, const DPoint2 &b)
 Returns the dot product of two DPoint2s.
 
constexpr DPoint2 operator* (const DPoint2 &a, double f)
 Multiply a DPoint2 by a scalar.
 
constexpr DPoint2 operator* (double f, const DPoint2 &a)
 
constexpr DPoint2 operator+ (const DPoint2 &a, double f)
 
constexpr DPoint2 operator+ (double f, const DPoint2 &a)
 
constexpr DPoint2 operator- (const DPoint2 &a, float f)
 
DPoint2 operator/ (const DPoint2 &a, double f)
 Divide a DPoint2 by a scalar.
 
constexpr Point2 Point2FromDPoint2 (const DPoint2 &from)
 
int DoublePrecisionLineSegmentIntersection (const DPoint2 &seg1Start, const DPoint2 &seg1End, const DPoint2 &seg2Start, const DPoint2 &seg2End, DPoint2 &intersectPoint)
 Double-Precision Line Segment Intersection test.
 
int DoublePrecisionLineIntersection (const DPoint2 &line1PointA, const DPoint2 &line1PointB, const DPoint2 &line2PointA, const DPoint2 &line2PointB, DPoint2 &intersectPoint)
 Double-Precision Line Intersection test.
 

Function Documentation

◆ Length()

double Length ( const DPoint2 p)
inline

Returns the 'Length' of the point.

This is sqrt(v.x*v.x+v.y*v.y)

Parameters
pthe DPoint2 to test
Returns
the length value
272{
273 return p.Length();
274}
double Length() const
Returns the 'Length' of this point (vector).
Definition: dpoint2.h:233

◆ LengthSquared()

constexpr double LengthSquared ( const DPoint2 p)
constexpr

The 'Length' squared of this point.

This is v.x*v.x+v.y*v.y.

Parameters
pthe DPoint2 to test
Returns
the length value
279{
280 return p.LengthSquared();
281}
constexpr double LengthSquared() const
The 'Length' squared of this point.
Definition: dpoint2.h:225

◆ MaxComponent()

int MaxComponent ( const DPoint2 p)
inline

Returns the component with the maximum absolute value.

Parameters
pthe DPoint2 to test
Returns
the maximum component (0=x, 1=y).
287{
288 return p.MaxComponent();
289}
int MaxComponent() const

◆ MinComponent()

int MinComponent ( const DPoint2 p)
inline

Returns the component with the minimum absolute value.

0=x, 1=y.

Parameters
pthe DPoint2 to test
Returns
the minimum component (0=x, 1=y).
294{
295 return p.MinComponent();
296}
int MinComponent() const

◆ Normalize()

DPoint2 Normalize ( const DPoint2 p)
inline

Returns a unit vector.

This is a DPoint2 with each component divided by the point Length().

Parameters
pthe DPoint2 to test
Returns
the unit vector for the specified DPoint2
303{
304 return p.Normalize();
305}
DPoint2 Normalize() const
Returns a unit vector.

◆ DotProd()

constexpr double DotProd ( const DPoint2 a,
const DPoint2 b 
)
constexpr

Returns the dot product of two DPoint2s.

309{
310 return a % b;
311}
float float b
Definition: texutil.h:51
float a
Definition: texutil.h:51

◆ operator*() [1/2]

constexpr DPoint2 operator* ( const DPoint2 a,
double  f 
)
constexpr

Multiply a DPoint2 by a scalar.

Parameters
athe DPoint2
fthe multiplier
Returns
the resulting DPoint2
318{
319 return DPoint2(a.x * f, a.y * f);
320}
Description: This class describes a 2D point using double precision x and y coordinates.
Definition: dpoint2.h:24

◆ operator*() [2/2]

constexpr DPoint2 operator* ( double  f,
const DPoint2 a 
)
constexpr
322{
323 return a * f;
324}

◆ operator+() [1/2]

constexpr DPoint2 operator+ ( const DPoint2 a,
double  f 
)
constexpr
Remarks
Returns a copy of the DPoint2 argument offset by (f, f).
328{
329 return DPoint2(a.x + f, a.y + f);
330}

◆ operator+() [2/2]

constexpr DPoint2 operator+ ( double  f,
const DPoint2 a 
)
constexpr
332{
333 return a + f;
334}

◆ operator-()

constexpr DPoint2 operator- ( const DPoint2 a,
float  f 
)
constexpr
Remarks
Returns a copy of the DPoint2 argument offset by (-f, -f).
338{
339 return a + -f;
340}

◆ operator/()

DPoint2 operator/ ( const DPoint2 a,
double  f 
)
inline

Divide a DPoint2 by a scalar.

Parameters
athe DPoint2
fthe divisor
Returns
the resulting DPoint2
347{
348 assert(f != 0.0);
349 return a * (1.0 / f);
350}
#define assert(expr)
Definition: assert1.h:82

◆ Point2FromDPoint2()

constexpr Point2 Point2FromDPoint2 ( const DPoint2 from)
constexpr
354{
355 return Point2(from.x, from.y);
356}
double y
Definition: dpoint2.h:27
double x
Definition: dpoint2.h:26
Definition: point2.h:38

◆ DoublePrecisionLineSegmentIntersection()

int DoublePrecisionLineSegmentIntersection ( const DPoint2 seg1Start,
const DPoint2 seg1End,
const DPoint2 seg2Start,
const DPoint2 seg2End,
DPoint2 intersectPoint 
)

Double-Precision Line Segment Intersection test.

Determines if two line segments intersect.

Parameters
seg1Startendpoint 1 for the first line segment
seg1Endendpoint 2 for the first line segment
seg2Startendpoint 1 for the second line segment
seg2Endendpoint 2 for the second line segment
intersectPointif the lines intersect, this will return the intersection point.
Returns
Intersection determination (0: No intersection, 1: Lines intersect (intersection location in 'intersectPoint'), 2: Lines parallel (no intersection))

◆ DoublePrecisionLineIntersection()

int DoublePrecisionLineIntersection ( const DPoint2 line1PointA,
const DPoint2 line1PointB,
const DPoint2 line2PointA,
const DPoint2 line2PointB,
DPoint2 intersectPoint 
)

Double-Precision Line Intersection test.

Determines if two infinite lines cross, and if so, where.

Parameters
line1PointApoint 1 on the first line
line1PointBpoint 2 on the first line
line2PointApoint 1 on the second line
line2PointBpoint 2 on the second line
intersectPointif the lines intersect, this will return the intersection point.
Returns
Intersection determination (0: Lines parallel, 1: Lines intersect (intersection location in 'intersectPoint'))