IfcCrossProduct

Natural language names
Cross Product
Semantic definitions at the function
Function Definition

NOTE  Definition according to ISO/CD 10303-42:1992
This function returns the vector (or cross) product of two input directions. The input directions must be three-dimensional. The result is always a vector which is unitless. If the input directions are either parallel or anti-parallel a vector of zero magnitude is returned.

NOTE  Function adapted from cross_product defined in ISO 10303-42.

HISTORY  New function in IFC1.5

Formal representations
EXPRESS Specification

FUNCTION IfcCrossProduct
  (Arg1, Arg2 : IfcDirection)
    : IfcVector;
LOCAL
  Mag : REAL;
  Res : IfcDirection;
  V1,V2  : LIST[3:3] OF REAL;
  Result : IfcVector;
END_LOCAL;

  IF (NOT EXISTS (Arg1) OR (Arg1.Dim = 2)) OR (NOT EXISTS (Arg2) OR (Arg2.Dim = 2)) THEN
    RETURN(?);
  ELSE
    BEGIN
      V1  := IfcNormalise(Arg1)\IfcDirection.DirectionRatios;

      V2  := IfcNormalise(Arg2)\IfcDirection.DirectionRatios;
      Res := IfcRepresentationItem() || IfcGeometricRepresentationItem ()
             || IfcDirection([(V1[2]*V2[3] - V1[3]*V2[2]), (V1[3]*V2[1] - V1[1]*V2[3]), (V1[1]*V2[2] - V1[2]*V2[1])]);
      Mag := 0.0;
      REPEAT i := 1 TO 3;
        Mag := Mag + Res.DirectionRatios[i]*Res.DirectionRatios[i];
      END_REPEAT;
      IF (Mag > 0.0) THEN
        Result := IfcRepresentationItem() || IfcGeometricRepresentationItem () || IfcVector(Res, SQRT(Mag));
      ELSE
        Result := IfcRepresentationItem() || IfcGeometricRepresentationItem () || IfcVector(Arg1, 0.0);
      END_IF;
      RETURN(Result);
    END;
  END_IF;

END_FUNCTION;

References  References: IfcAxis2Placement3D IfcAxis2PlacementLinear

Link to this page  Link to this page