dvec2d.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
11 #ifndef dvec2d_H_
12 #define dvec2d_H_
13 
15 
16 
17 
18 #ifdef __cplusplus
19 
25 struct GEOMDLLIMPEXP DVec2d : public DPoint2d
26 {
27 
28 
29 
31 static DVec2d From (double x, double y);
33 void Init (double ax, double ay);
34 
37 static DVec2d From (DPoint2dCR point);
40 void Init (DPoint2dCR point);
41 
43 void Zero ();
44 
46 void One ();
47 
48 
49 
50 
54 static DVec2d FromStartEnd (DPoint2dCR start, DPoint2dCR end);
55 
58 void Negate (DVec2dCR vector);
59 
61 void Negate ();
62 
63 
64 
65 
66 
70 void SumOf (DVec2dCR vector1, DVec2dCR vector2);
71 
74 void Add (DVec2dCR vector);
75 
79 static DVec2d FromScale (DVec2dCR vector, double scale);
80 
84 void Scale (DVec2dCR vector, double scale);
85 
90 void Scale (double scale);
91 
92 
98 static DVec2d FromSumOf (DVec2dCR vector0, double scale0, DVec2dCR vector1, double scale1);
99 
107 static DVec2d FromSumOf (DVec2dCR vector0, double scale0, DVec2dCR vector1, double scale1, DVec2dCR vector2, double scale2);
108 
109 
110 
115 void SumOf (DVec2dCR origin, DVec2dCR vector, double scale);
116 
123 void SumOf (DVec2dCR origin, DVec2dCR vector1, double scale1, DVec2dCR vector2, double scale2);
124 
133 void SumOf (DVec2dCR origin, DVec2dCR vector1, double scale1, DVec2dCR vector2, double scale2, DVec2dCR vector3, double scale3);
134 
135 
136 
140 void DifferenceOf (DVec2dCR vector1, DVec2dCR vector2);
141 
145 void DifferenceOf (DPoint2dCR target, DPoint2dCR base);
146 
147 
151 void Subtract (DVec2dCR vector2);
152 
160 double NormalizedDifference (DPoint2dCR target, DPoint2dCR origin);
161 
162 
167 double Normalize (DVec2dCR vector);
168 
176 double Normalize ();
177 
178 
185 double ScaleToLength (DVec2dCR vector, double length);
186 
195 double ScaleToLength (double length);
196 
197 
198 
207 bool SafeDivide (DVec2dCR vector, double denominator);
208 
209 
210 
211 
216 static DVec2d FromInterpolate (DVec2dCR vector0, double fraction, DVec2dCR vector1);
217 
218 
219 
229 void Interpolate (DVec2dCR vector0, double fractionParameter, DVec2dCR vector1);
230 
238 static DVec2d FromInterpolateBilinear (DVec2dCR vector00, DVec2dCR vector10, DVec2dCR vector01, DVec2dCR vector11, double u, double v);
239 
240 
244 void RotateCCW (DVec2dCR vector, double theta);
245 
248 void RotateCCW (double theta);
249 
254 bool UnitPerpendicular (DVec2dCR vector);
255 
256 
260 void XyOf (DPoint4dCR hPoint);
261 
262 
263 
266 double MagnitudeSquared () const;
267 
270 double Magnitude () const;
271 
276 double MaxAbs () const;
277 
278 
285 double Distance (DVec2dCR vector2) const;
286 
293 double DistanceSquared (DVec2dCR vector2) const;
294 
295 
296 
297 
298 
299 
300 
309 double GetComponent (int index) const;
310 
317 void SetComponent (double a, int index);
318 
324 void GetComponents (double &xCoord, double &yCoord);
325 
326 
327 
328 
329 
333 double DotProduct (DVec2dCR vector2) const;
339 double DotProduct (double ax, double ay) const;
340 
341 
346 double DotProduct (DPoint2dCR point2) const;
347 
348 
351 double CrossProduct (DVec2dCR vector2) const;
352 
355 double CrossProductSquared (DVec2dCR vector2) const;
356 
357 
358 
364 double AngleTo (DVec2dCR vector2) const;
365 
374 double SmallerUnorientedAngleTo (DVec2dCR vector2) const;
375 
376 
397 bool IsVectorInSmallerSector (DVec2dCR vector0, DVec2dCR vector1) const;
398 
402 bool IsVectorInCCWSector (DVec2dCR vector0, DVec2dCR vector1) const;
403 
404 
405 
406 
413 bool IsParallelTo (DVec2dCR vector2) const;
414 
421 bool IsPerpendicularTo (DVec2dCR vector2) const;
422 
423 
429 bool IsEqual (DVec2dCR vector2) const;
430 
441 bool IsEqual
442 (
443 DVec2dCR vector2,
444 double tolerance
445 ) const;
446 
453 bool AlmostEqual (DVec2d const & dataB) const;
454 
455 
456 };
457 #endif
458 
460 
461 #endif // dvec2d_H_
double AngleTo(DPoint2dCR vector2) const
Returns (signed, counterclockwise) angle between two vectors.
double MaxAbs() const
Finds the largest absolute value among the components of a point or vector.
struct DVec2d const & DVec2dCR
Definition: msgeomstructs_typedefs.h:90
void Add(DPoint2dCR vector)
Add a vector to the instance.
double Magnitude() const
Returns the magnitude (length) of a vector.
double GetComponent(int index) const
Gets a single component of a point.
double DotProduct(DPoint2dCR vector2) const
Returns the (scalar) dot product of two vectors.
void GetComponents(double &xCoord, double &yCoord) const
static DPoint2d FromInterpolate(DPoint2dCR point0, double fraction, DPoint2dCR point1)
Returns an interpolated point.
void Init(double x, double y)
Initialize with given components.
iterator end()
Definition: stdcxx/bstdmap.h:186
void Subtract(DPoint2dCR vector)
Subtract one vector from another in place.
Vector with x,y components.
Definition: dvec2d.h:25
void SetComponent(double a, int index)
Sets a single component of a point.
#define BEGIN_BENTLEY_NAMESPACE
Definition: Bentley.r.h:24
double Distance(DPoint2dCR point1) const
Returns the distance between 2 points.
double Normalize()
normalizes pVector1 in place, and returns the original magnitude.
void Negate(DPoint2dCR vector)
returns the negative of a vector.
static DPoint2d FromScale(DPoint2d point, double scale)
Returns a scalar multiple of a DPoint2d.
struct DPoint2d const & DPoint2dCR
Definition: msgeomstructs_typedefs.h:78
void DifferenceOf(DPoint2dCR point1, DPoint2dCR point2)
Return the difference of two points or vectors.
double CrossProduct(DPoint2dCR vector1) const
Returns the (scalar) cross product of two vectors.
static DPoint2d From(double ax, double ay)
Returns a DPoint2d with 2 components (xy) from given components.
bool AlmostEqual(DPoint2d const &dataB) const
test if two points are equal.
bool IsPerpendicularTo(DPoint2dCR vector2) const
Test if two vectors are perpendicular.
double DistanceSquared(DPoint2dCR point2) const
Return the squared distance between two points or vectors.
void Scale(DPoint2dCR source, double s)
Scale the instance coordinates from source.
void RotateCCW(DPoint2dCR vec, double radians)
void SumOf(DPoint2dCR point1, DPoint2dCR point2)
Compute the sum of two points or vectors.
bool IsParallelTo(DPoint2dCR vector2) const
Test if two vectors are parallel.
#define END_BENTLEY_NAMESPACE
Definition: Bentley.r.h:25
double ScaleToLength(DPoint2dCR source, double length)
Scales a vector to specified length.
void Interpolate(DPoint2dCR point0, double s, DPoint2dCR point1)
Compute the point at an interpolated (fractional) position between a start and end point...
void Zero()
Sets all components of a point or vector to zero.
static DPoint2d FromSumOf(DPoint2dCR point0, double scale0, DPoint2dCR point1, double scale1)
Returns a linear combination of points.
struct DPoint4d const & DPoint4dCR
Definition: msgeomstructs_typedefs.h:96
bool IsEqual(DPoint2dCR vector2) const
Test if two points or vectors are exactly equal.
double MagnitudeSquared() const
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)
void One()
Returns a point or vector with all components 1.0.
2d point coordinates.
Definition: dpoint2d.h:23

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