Thursday, August 8, 2013

Parametric Curves - Basic Concepts

This article explains few basic concepts related to parametric curves using Rhino 5 and Grasshopper 0.9.

CURVE PARAMETER
Parametric curves are defined using a parameter. Think of a parametric curve as a path traveled between two points.  If traveling takes T amount of time, then the parameter "t" represents any point in time within T, where the traveler will be at some point within the path.

For example, the parametric line equation is defined as:
P = P0 + t*v
where
P: is any point on the line
P0: is a given point on the line
t: is a parameter on the line, and
v: is a vector and represents the direction of the line.

Now suppose we have a straight path (linear curve) between the two points A and B, and v was a vector from A to B (v=B-A). We can use the parametric line equation to find all points "M" between A and using the parametric line equation above:
M = A + t*(B-A)
where
t: is any value between 0 and 1

The range of "t" values, which are 0 to 1 in this case, is referred to as the curve "domain" or "interval".  If "t" was a value outside the domain (less that 0 or more than 1 in this case), then the resulting point M will be outside the linear curve AB.

CURVE DOMAIN:
A curve domain is defined as the range of parameters that evaluate into a point within that curve. The domain is usually described as two real numbers (min to max) or (min,max).  The domain limits can be any two values that may or may not be related to the curve actual length. However, it is very common that the domain be set to (0 to 1).
Changing a curve domain is referred to as "reparameterize" the curve. In Grasshopper, you can set the curve domain to (0 to 1) using the "Reparameterize" option on any curve input. Also there is a Rhino command "Reparamterize" that allows you to set any min and max domain values. The following example in GH reparameterize the above curve domain to be (0-1):

An increasing domain means that the minimum value of the domain points to the start of the curve. Domains are typically increasing, but not always.

EVALUATE A CURVE
Evaluating a curve at a parameter that is within the curve domain results in a point that is "on" the curve. The following example curve has a domain (0 to 1). It shows how to evaluate the curve at mid-domain parameter (t = 0.5). Notice that parameter value that is in the middle of the domain might not evaluate into the middle point along the curve.
That brings us to the concept of parameter density of a parametric curve.  Using the traveling metaphor used above, you can think of uniform parameter density of a curve as traveling a path with constant speed.  It is though possible (and more likely) that the speed decreases or increases along the path.  For example, if it takes 30 minutes to travel a road, it is unlikely that you will be exactly half way through at minute 15. However, there are times when you need to evaluate points on a curve that are at a defined percentage of the curve length.  For example, you might need the mid point of a curve. In order to achieve that, you need to find the parameter "t" at mid point and then evaluate the curve at that parameter. This parameter is called "normalized parameter". The following example evaluates a normalized mid domain parameter (t=0.5) for a curve that has domain (0 to 1).

TANGENT VECTOR TO A CURVE
A tangent to a smooth curve at any parameter (or point) is the vector that touches the curve at that point, but does not cross over.  The slope of the tangent vector equals the slope of the curve at the same point. The following example evaluate the tangent at the two points defined in the above two examples.

No comments:

Post a Comment