# FUNCTION normalise

```(* SCHEMA geometry_schema; *)
```
``` FUNCTION normalise (arg : vector_or_direction) : vector_or_direction;
LOCAL
ndim   : INTEGER;
v      : direction;
result : vector_or_direction;
vec    : vector;
mag    : REAL;
END_LOCAL;

IF NOT EXISTS (arg) THEN
result := ?;
(* When function is called with invalid data a NULL result is returned *)
ELSE
ndim := arg.dim;
IF 'GEOMETRY_SCHEMA.VECTOR' IN TYPEOF(arg) THEN
BEGIN
v := dummy_gri || direction(arg\vector.orientation.direction_ratios);
IF arg.magnitude = 0.0 THEN
RETURN(?);
ELSE
vec := dummy_gri || vector (v, 1.0);
END_IF;
END;
ELSE
v := dummy_gri || direction (arg.direction_ratios);
END_IF;
mag := 0.0;
REPEAT  i := 1 TO ndim;
mag := mag + v.direction_ratios[i]*v.direction_ratios[i];
END_REPEAT;
IF mag > 0.0 THEN
mag := SQRT(mag);
REPEAT  i := 1 TO ndim;
v.direction_ratios[i] := v.direction_ratios[i]/mag;
END_REPEAT;
IF 'GEOMETRY_SCHEMA.VECTOR' IN TYPEOF(arg) THEN
vec.orientation := v;
result := vec;
ELSE
result := v;
END_IF;
ELSE
RETURN(?);
END_IF;
END_IF;
RETURN (result);
END_FUNCTION;
```

## Referenced By

Defintion normalise is references by the following definitions:
DefinitionType
axis1_placement ENTITY
base_axis FUNCTION
build_2axes FUNCTION
build_axes FUNCTION
build_direction_node FUNCTION
convert_spatial_to_ypr_rotation FUNCTION
cross_product FUNCTION
dot_product FUNCTION
first_proj_axis FUNCTION
scalar_times_vector FUNCTION
second_proj_axis FUNCTION
vector_difference FUNCTION
vector_sum FUNCTION

[Top Level Definitions] [Exit]

Generated by STEP Tools® EXPRESS to HTML Converter
2012-03-27T17:13:58-04:00