TVectorNormalize (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example illustrates how to use the Normalize method for normalizing a vector.

Code

#include <System.Types.hpp>

int _tmain(int argc, _TCHAR* argv[]) {
	TVector *vector1 = new TVector();
	TVector *vector2 = new TVector();
	vector1->X = 1;
	vector1->Y = 2;

	*vector2=vector1->Scale(factor);
	printf("%2.3f %2.3f", vector2->X, vector2->Y);
        // The console will output:  0.447 0.894 , representing the coordinates of vector2 obtained by scaling vector1

	return 0;
}

Uses