TVector3DNormalize (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the Normalize method to return the normalized 3D vector of This.

Code

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

int _tmain(int argc, _TCHAR* argv[])
{
	TVector3D *aVector1=new TVector3D(1,-20,8,1);
	printf("%2.2f %2.2f %2.2f\n",aVector1->X,aVector1->Y,aVector1->Z);
	// The console will output: 1.00 -20.00 8.00, representing the coordinates for aVector1.

	aVector1->Normalize();
	printf("%2.2f %2.2f %2.2f\n",aVector1->X,aVector1->Y,aVector1->Z);
	// The console will output: 0.05 -0.93 0.37, representing the coordinates for aVector1 after normalization.
	return 0;
}

Uses