Click here to Skip to main content
15,894,172 members
Articles / Desktop Programming / MFC

Scientific charting control

Rate me:
Please Sign up or sign in to vote.
4.84/5 (122 votes)
17 Jan 20055 min read 1.3M   42.6K   405  
Multi-purpose scientific charting control.
#if !__VECTOR2D_H
#define __VECTOR2D_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#define MPOINT2POINT(mpt, pt)   ((pt).x = (mpt).x, (pt).y = (mpt).y)
#define POINT2MPOINT(pt, mpt)   ((mpt).x = (SHORT)(pt).x, (mpt).y = (SHORT)(pt).y)
#define POINTS2VECTOR2D(pt0, pt1, vect) ((vect).x = (double)((pt1).x - (pt0).x), \
                                         (vect).y = (double)((pt1).y - (pt0).y))
typedef struct tagVECTOR2D  {
        double     x;
		double     y;
} VECTOR2D, *PVECTOR2D, FAR *LPVECTOR2D; 

typedef struct tagPROJECTION  {
        VECTOR2D   ttProjection;
		VECTOR2D   ttPerpProjection;
        double     LenProjection;
		double     LenPerpProjection;
} PROJECTION, *PPROJECTION, FAR *LPPROJECTION; 

typedef struct tagPOINTNORMAL  {
        VECTOR2D   vNormal;
		double     D;
} POINTNORMAL, *PPOINTNORMAL, FAR *LPPOINTNORMAL;

PVECTOR2D  vSubtractVectors(PVECTOR2D v0, PVECTOR2D v1, PVECTOR2D v);
PVECTOR2D  vAddVectors(PVECTOR2D v0, PVECTOR2D v1, PVECTOR2D v);
PVECTOR2D  vScaleVector(PVECTOR2D v0, double dScaling, PVECTOR2D v);
PVECTOR2D  vLinearCombination(PVECTOR2D ptScale, PVECTOR2D v0, PVECTOR2D v1, PVECTOR2D v);
double     vVectorSquared(PVECTOR2D v0);
double     vVectorMagnitude(PVECTOR2D v0);
void       vNormalizeVector(PVECTOR2D ptN);
double     vDotProduct(PVECTOR2D v, PVECTOR2D v1);
PVECTOR2D  vNormalVector(PVECTOR2D v0, PVECTOR2D v);
BOOL       vPointNormalForm(POINT pt0, POINT pt1, PPOINTNORMAL ppnPointNormal);
void       vProjectAndResolve(PVECTOR2D v0, PVECTOR2D v1, PPROJECTION ppProj);
BOOL       vIsPerpendicular(PVECTOR2D v0, PVECTOR2D v1);
double     vVectorAngle(PVECTOR2D v0, PVECTOR2D v1);
double     vDistFromPointToLine(LPPOINT pt0, LPPOINT pt1, LPPOINT ptTest);

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions