TPoint3DCrossProduct (C++)

From RAD Studio Code Examples
Jump to: navigation, search


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


#include <System.Types.hpp>

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);
        //initialize a new TPoint3D with null coordinates that acts as a placeholder for the cross product between the previous two points.
	TPoint3D *result = new TPoint3D(0,0,0);
	//compute the CrossProduct of aPoint1 and another point. In this case, aPoint2.

	*result = aPoint1->CrossProduct(*aPoint2);
	printf("The X-axis result: %f\n", result->X);
	printf("The Y-axis result: %f\n", result->Y);
	printf("The Z-axis result: %f\n", result->Z);
	return 0;