MinPoint (C++)

From Appmethod Code Examples
Jump to: navigation, search

Description

The following code example illustrates how to use the MinPoint function to return the minimum of two TPointF or TPoint objects.

Code

#include <System.Types.hpp>

int _tmain(int argc, _TCHAR* argv[]) {
	TPoint *aPoint = new TPoint(3, 4);
	TPoint *aSecondPoint = new TPoint(10, 5);
	TPoint *aThirdPoint = new TPoint();

	*aThirdPoint = MinPoint(*aPoint, *aSecondPoint);
	// Returns the point that is closer to the origin((0,0) coordinates).
	printf("Coordinates: %d %d", aThirdPoint->X, aThirdPoint->Y);
	// As seen above, the Y-coordinates of P1 and P2 are equal.
	// The program then compares the X-coordinates and returns the minimum point.
	getchar();
	return 0;
}

Uses