![]() | Scalar Times Vector |
NOTE Definition according to ISO/CD 10303-42:1992
This function returns the vector that is the scalar multiple of the input vector. It accepts as input a scalar and a 'vector' which may be either a Direction or a Vector. The output is a Vector of the same units as the input vector or unitless if a direction is input. If either input argument is undefined then the returned vector is also undefined.
NOTE Function adapted from scalar_times_vector defined in ISO 10303-42.
HISTORY New function in IFC1.5
FUNCTION IfcScalarTimesVector
(Scalar : REAL; Vec : IfcVectorOrDirection)
: IfcVector;
LOCAL
V : IfcDirection;
Mag : REAL;
Result : IfcVector;
END_LOCAL;
IF NOT EXISTS (Scalar) OR NOT EXISTS (Vec) THEN
RETURN (?) ;
ELSE
IF 'IFCGEOMETRYRESOURCE.IfcVector' IN TYPEOF (Vec) THEN
V := Vec\IfcVector.Orientation;
Mag := Scalar * Vec\IfcVector.Magnitude;
ELSE
V := Vec;
Mag := Scalar;
END_IF;
IF (Mag < 0.0 ) THEN
REPEAT i := 1 TO SIZEOF(V.DirectionRatios);
V.DirectionRatios[i] := -V.DirectionRatios[i];
END_REPEAT;
Mag := -Mag;
END_IF;
Result := IfcRepresentationItem() || IfcGeometricRepresentationItem () || IfcVector(IfcNormalise(V), Mag);
END_IF;
RETURN (Result);
END_FUNCTION;