FUNCTION vector_difference
(* SCHEMA step_merged_ap_schema; *)
-- DIFF IN AP214
-- DIFF IN AP203e2
-- DIFF IN AP224
-- DIFF IN AP232
FUNCTION vector_difference
(arg1 : vector_or_direction;
arg2 : vector_or_direction ) : vector;
LOCAL
result : vector;
res : direction;
vec1 : direction;
vec2 : direction;
mag : REAL;
mag1 : REAL;
mag2 : REAL;
ndim : INTEGER;
END_LOCAL;
IF (NOT EXISTS(arg1) OR NOT EXISTS(arg2)) OR (arg1.dim <> arg2.dim) THEN
RETURN (?);
ELSE
BEGIN
IF 'STEP_MERGED_AP_SCHEMA.VECTOR' IN TYPEOF(arg1) THEN
mag1 := arg1\vector.magnitude;
vec1 := arg1\vector.orientation;
ELSE
mag1 := 1.0;
vec1 := arg1;
END_IF;
IF 'STEP_MERGED_AP_SCHEMA.VECTOR' IN TYPEOF(arg2) THEN
mag2 := arg2\vector.magnitude;
vec2 := arg2\vector.orientation;
ELSE
mag2 := 1.0;
vec2 := arg2;
END_IF;
vec1 := normalise(vec1);
vec2 := normalise(vec2);
ndim := SIZEOF(vec1.direction_ratios);
mag := 0.0;
res := dummy_gri || direction(vec1.direction_ratios);
REPEAT i := 1 TO ndim;
res.direction_ratios[i] := mag1 * vec1.direction_ratios[i] - mag2 * vec2.direction_ratios[i];
mag := mag + res.direction_ratios[i] * res.direction_ratios[i];
END_REPEAT;
IF mag > 0.0 THEN
result := dummy_gri || vector(res, SQRT(mag));
ELSE
result := dummy_gri || vector(vec1, 0.0);
END_IF;
END;
END_IF;
RETURN (result);
END_FUNCTION;
Referenced By
Defintion vector_difference is references by the following definitions:
[Top Level Definitions] [Exit]Generated by STEP Tools® EXPRESS to HTML Converter
2020-07-28T17:02:20-04:00