SilverScreen Solid Modeler

SetMagnitude method

SetMagnitude method

Previous topic Next topic  

SetMagnitude method

Previous topic Next topic JavaScript is required for the print function  

SilverSharpAPI

 

bool SetMagnitude(double desired_magnitude);

 

double desired_magnitude;   // A double-precision floating point value

 

 

 




Synopsis

using SilverSharp;

 

The SetMagnitude method moves the 3D point along a directed vector through the origin such that its' magnitude becomes desired_magnitude

 

 

Parameters

desired_magnitude is the length of the line formed between the origin and the new 3D point.

 

 

Return Value

SetMagnitude returns true if the desired magnitude can be established, and false otherwise. If the original 3D point is equal to the origin, then an infinite number of direction vectors is described and the magnitude becomes meaningless unless it is zero.

 

 

Remarks

If SetMagnitude succeeds, then the new point will reside on the same line that is formed between the origin and the original point.

 

 

See Also

SS_XYZ, follow_vector

 

 

Example

The following code will create a point, p3, that is 5 units from p1 along the line formed between p1 and p2:

 

C# Code

 

 using SilverSharp;

 

 SS_XYZ p1 = new SS_XYZ(12.0, 15.0, 0.0);

 SS_XYZ p2 = new SS_XYZ(20.0, 17.5. 0.0);

 SS_XYZ direction = p2 - p1;

 

 direction.SetMagnitude(5.0);  // Direction vector has length = 5

 

 SS_XYZ p3 = p1 + direction;

 

 

Note: The SilverScreen API routine follow_vector can perform the above calculations more easily.