Daily Download 25: Vector Functions

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.

Download file:
http://interactiveds.com.au/software/VectorFunc.xlsb

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

Vector product functions

3D cross product and length

Posted in Excel, Maths, Newton, UDFs, VBA | Tagged , , , , , , | Leave a comment

Daily Download 24: Units for Excel

The Units4Excel spreadsheet provides:

  • User Defined Functions (UDFs) to convert between any listed units, including compound SI units.
  • A UDF to evaluate any function entered as text, including evaluation of input and output units.
  • Recognition of all standard SI prefixes.
  • An extensive list of non-SI units, based on the Wikipedia unit conversion page.
  • The ability to add any other units to the list.

The download file is: http://www.interactiveds.com.au/software/Units4Excel.zip

The most recent posts with further details are:

Units for Excel 4: Scripting dictionaries
Units for Excel 5:

Function index

ConvertA Function, with alternative input options

EvalU Function

Posted in Excel, Maths, Newton, UDFs, VBA | Tagged , , , , | 1 Comment

Daily Download 23: Trigonometric Functions in VBA and Fortran

The trigonometric functions provided in Excel omit some functions, and the functions provided in VBA are still more restricted.  Notably VBA does not provide an ATan2 function, which is required to define an angle over a full 360 degree range, based on X, Y coordinates.

The download files below provide the full range of functions, including all inverse functions and hyperbolic functions.  The VBA version should work in all versions of Excel from 2000 up, but the Fortran version links to a dll that requires a 32 bit operating system, and does not work in 64 bit versions of Windows.

VBA version: http://interactiveds.com.au/software/TrigFuncsVBA.zip
Fortran version (32 bit only): http://interactiveds.com.au/software/Trig%20Funcs%20dll.zip

Further details of the files are given at Trigonometric Functions in VBA and Trigonometric Functions in VBA – Update for the VBA version and Trigonometric Functions – dll for the Fortran dll version.

Trig Function Examples

Hyperbolic Function Examples

Posted in Coordinate Geometry, Excel, Link to dll, Maths, Newton, UDFs, VBA | Tagged , , , , , | 8 Comments

Daily Download 22: Splines and Curves

Since it was first published in 2009 my CSpline function has been the most popular download from this site.  CSpline (and various associated functions) is used to fit a series of cubic curves through specified points, allowing interpolation along a smooth curve.

The latest version of the spreadsheet is:
http://www.interactiveds.com.au/software/CSpline2.zip

The original function is described at Cubic Splines.  This was further developed in response to a reader query at Using Cubic Splines in Practice and Cubic Hermitic and Cardinal Splines, and most recently Spline Interpolation Alternatives provided some “on-sheet” methods with similar functionality.

Related spreadsheets were described in Daily Download 13: The ALGLIB maths library and Excel (covering the ALGLIB spline functions) and Daily Download 4: Continuous Beam Analysis (covering the use of cubic splines to model continuous beams, and the SplineBeam function).

The remaining curve generating spreadsheet is:
http://interactiveds.com.au/software/Catenary.zip

This includes a function to generate the coordinates of any specified catenary curve, with an option to find the tension force at any point.  For more details see A catenary function.

Fitting a cubic spline to five data points

Cubic Spline and alternative Hermite Splines

Interpolated and fitted curves with spikey data

Catenary UDF

Posted in AlgLib, Beam Bending, Charts, Charts, Coordinate Geometry, Excel, Newton, Numerical integration, UDFs, VBA | Tagged , , , , , , , , | 7 Comments

Daily Download 21: Assorted Solvers

Today’s download starts with some simple linear interpolation methods used to solve polynomial equations, leading on to more sophisticated methods using quadratic or inverse quadratic interpolation. Also included is a solver for differential equations using the Cash-Karp Method, which is a refinement of the Runge-Kutta Method.

The current download files are:

Newton’s method:
http://interactiveds.com.au/software/Newtons%20Method.zip
Quadratic and Inverse Quadratic interpolation:
http://interactiveds.com.au/software/ItSolve%20Functions.xls
Brent’s Method
http://www.interactiveds.com.au/software/ItSolve.zip
Ordinary differential equation solver (Cash-Karp Method)
http://interactiveds.com.au/software/ODESolver.zip

More details are given in the following posts:

Approximate Solutions of Polynomial Equations
Function roots with the Inverse Quadratic Method
The Inverse Quadratic Method – 2
The Inverse Quadratic Method 3 – Brent’s Method
Using the AlgLib ODE (Runge-Kutta) Solver with Excel

Basis of the Newton-Raphson Method

Inverse Quadratic Method

Muller’s Method and Brent’s Method functions

Damped Vibration System differential equations

Damped vibration system solution

Buckling load of a column using ODE solver function

Posted in AlgLib, Beam Bending, Differential Equations, Excel, Maths, Newton, UDFs, VBA | Tagged , , , , , , , , , , | Leave a comment