Today’s download file provides a variety of vector arithmetic functions, which can be used either from other VBA routines, or on the spreadsheet as User Defined Functions.
In addition to Dot and Cross the spreadsheet contains the following vector related functions (optional function arguments are shown in italics):
- Length(Vect1, Vect2) returns the length of a vector from the origin if only Vect1 is specified, or the length between Vect1 and Vect2 if both are specified.
- isLeft(P1, P2, P3) tests if P3 is left or Right of the line through P1 and P2. The magnitude of the return value is also twice the area of the triangle specified by P1, P2, P3. Note that isLeft cannot be called as a UDF.
- Orientation2D_Triangle(P1, P2, P3) calls isLeft, and returns the same value. It may be called as a UDF.
- Area2D_Triangle(P1, P2, P3) calls Orientation2D_Triangle, and divides the result by -2, returning the area of the triangle P1P2P3, with a positive area when the points are specified in a clockwise direction.
- Area2D(Pointrange) returns the area of a 2D polygon with any number of points. The points are assumed to be arranged in a range of n rows x 2 columns (X and Y values), with the last point being the same as the first.
- Area3D(Pointrange) returns the area of a 3D polygon in a plane with any number of points. The points are assumed to be arranged in a range of n rows x 3 columns (X, Y and Z values), with the last point being the same as the first. If the points are not on a common plane it will return the area of the polygon projected onto the plane defined by the first three points.
- UnitNorm(Pointrange) returns the unit normal to a plane specified by the 3D points in Pointrange. The points are assumed to be arranged in a range of n rows x 3 columns (X, Y and Z values)
More details at: Dots and Crosses