SilverScreen Solid Modeler

GetMagnitudeSquared method

GetMagnitudeSquared method

Previous topic Next topic  

GetMagnitudeSquared method

Previous topic Next topic JavaScript is required for the print function  

SilverSharpAPI

 

double GetMagnitudeSquared();

 

 

 

 

 




Synopsis

using SilverSharp;

 

The GetMagnitudeSquared method measures the squared distance from the w-space origin (0,0,0) to the 3D point stored in the SilverSharp.SS_XYZ object. Often the squared distance is useful in sorting as a way to avoid calculating a square root.

 

Parameters

none

 

Return Value

GetMagnitudeSquared returns the squared distance of the 3D point from the origin.

 

Remarks

Given an x, y, and z-coordinate the squared magnitude is computed as follows:

 

  (x * x) + (y * y) + (z * z);

 

 

See Also

SS_XYZ

 

Example

The following code measures the squared magnitude of the 3D vector 5,0,0:

 

 

C# Code

 

 using SilverSharp;

 

 . . .

 

 SS_XYZ pt = new SS_XYZ(5.0, 0.0,  0.0);

 double val;

 

 val = pt.GetMagnitudeSquared(); // = 5*5 + 0*0 + 0*0