CatmullRomSpline

Synopsis

Generates a Catmull-Rom spline from a series of 2D or 3D coordinates.


  module CatmullRomSpline < build_dir="iac_proj/catmull",
                          src_file="catmull.c",
                          out_src_file="gen.cxx",
                          out_hdr_file="gen.h",
                   		  c_src_files="spline.c",
                          c_hdr_files="spline.h"> {
      float points<NEportLevels={2,0}>[];
      CatmullParams &CatmullParams <NEportLevels={2,0}>;
      omethod+notify_inst+req update(
         .points+read+notify+req,
         .line_type+read+notify,
         .steps+read+notify,
         .nspace+read,
         .out+write
      ) = "update";
      int line_type => CatmullParams.line_type;
      int steps => CatmullParams.steps;
      float dims[] => array_dims(points);
      int nspace => (array_size(points) / dims[1]);
      float out<NEportLevels={0,2}>[((((array_size(.points) / .nspace) - .line_type) * .steps) + 1)][.nspace];
  };
};

Description

CatmullRomSpline is a low level module that takes a series of either 2D or 3D floating point coordinates and generates a spline that passes through all the points with C1 continuity. The spline is then output as a similar series of coordinates, the number of which is determined by the number of steps required. If these points are to be displayed they then have to be converted into a mesh.

Inputs

&points

Reference to an array of floating point coordinates which are to be used as the nodes that the spline curve connects. Coordinates can be either 2 or 3 dimensional and should be represented by arrays of the form [n][2] and [n][3] respectively, where n is the number of nodes. A spline curve is then generated that connects the nodes together in the order given.

&CatmullParams

Reference to the parameter block, which contains real instances of the parameters for the CatmullRomSpline function.

steps

Number of line segments to be used to smooth the line between two points. The parameter is of type int. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &CatmullParams input.

line_type

      enum line_type { choices => {"closed","open"}; } = "closed";

Defines whether the spline is closed or left open. The parameter is an enumeration of two values, this is defined using the code above. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &CatmullParams input.

Outputs

out

The generated spline curve represented as a series of floating point coordinates along the spline. The number of coordinates generated is determined by the steps parameter. The resultant array is of the same form as the input array. Therefore for a closed 3D spline the output array would have the following dimensions [(n * steps) + 1][3] where n is the original number of nodes.

Utility Macros

The low-level CatmullRomSpline module is used in the User Macro catmull. Additionally, this macro also uses the CatmullParams parameter block group object, as does the CatmullUI UI Macro.

Example

An example application CatmullEg is provided, which takes an array of 8 3D coordinates and smoothes the polyline between them by calculating a Catmull-Rom spline curve.

Files

iac_proj/catmull/ctmlmods.v contains the CatmullParams group and the CatmullRomSpline module V definitions.

Other Notes

The low-level CatmullMods library containing the module CatmullRomSpline does not specify a process. By default the express process will be used.

Authors

Mario Valle

Modifications

Paul G. Lever
Andrew Dodd

Contact

International AVS Centre
Manchester Visualization Centre
Manchester Computing
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL

See Also

CatmullParams, CatmullUI, catmull