TPoint3DDotProduct (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the DotProduct method to get the scalar product between two 3D points.

Code

int _tmain(int argc, _TCHAR* argv[])
{
	//create two instances of a TPoint3D with different coordinates.
	TPoint3D *aPoint1 = new TPoint3D(2.6, 3.3, 8.7);
	TPoint3D *aPoint2 = new TPoint3D(10.8, 16.5, 1.7);
	float result;

	//compute the DotProduct of aPoint1 and another point. In this case, aPoint2.
	result = aPoint1->DotProduct(*aPoint2);
	printf("The dot product of the two points is: %f", result);
	getchar();
	return 0;
}

Uses