TVector3DCrossProduct (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the CrossProduct method to obtain the cross product of This and a given TVector3D value.

Code

#include <tchar.h>
#include <stdio.h>
#include <system.types.hpp>

int _tmain(int argc, _TCHAR* argv[])
{
	float aValue;

	TVector3D *aVector1=new TVector3D(1,1,0,1);
	printf("%2.2f %2.2f %2.2f\n",aVector1->X,aVector1->Y,aVector1->Z);
	// The console will output: 1.00 1.00 0.00, representing the coordinates for aVector1.

	TVector3D *aVector2= new TVector3D(4,7,3,1);
	printf("%2.2f %2.2f %2.2f\n",aVector2->X,aVector2->Y,aVector2->Z);
	// The console will output: 4.00 7.00 3.00, representing the coordinates for aVector2.

	*aVector1 = aVector1->CrossProduct(*aVector2);
	printf("%2.2f %2.2f %2.2f\n",aVector1->X,aVector1->Y,aVector1->Z);
	// The console will output: 3.00 -3.00 3.00, representing the coordinates for aVector1 as the cross product of aVector1 and aVector2.   

	return 0;
}

Uses