Quadratic Curve Derivatives help, Please

Quadratic Curve Derivatives help, Please

Post by =·MoLe » Mon, 05 May 2003 20:37:11



Hi All

I am building a small vinyl cutting machine, could somebody tell me how to
get the first & second derivatives of a quadratic b-spline
as used in a truetype font outline, below is the code used to generate the
x&y points, I'm not too crash hot on math :(

tval  =  value of t along curve
A,B,C the control points.
//--------------------------------------------------
t  = 1.0 - tval
n1 = t * t
n2 = 2.0 * tval * t2
n3 = tval * tval

point_x = n1 * Ax + n2 * Bx + n3 * Cx;
point_y = n1 * Ay + n2 * By + n3 * Cy;

dt1 ?
dt2 ?
//--------------------------------------------------------------------------

Thanks for any help.

Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Just d' FAQ » Tue, 06 May 2003 01:35:20




Quote:>I am building a small vinyl cutting machine, could somebody tell me how to
>get the first & second derivatives of a quadratic b-spline
>as used in a truetype font outline, below is the code used to generate the
>x&y points, I'm not too crash hot on math :(

>tval  =  value of t along curve
>A,B,C the control points.
>//--------------------------------------------------
>t  = 1.0 - tval
>n1 = t * t
>n2 = 2.0 * tval * t2
>n3 = tval * tval

>point_x = n1 * Ax + n2 * Bx + n3 * Cx;
>point_y = n1 * Ay + n2 * By + n3 * Cy;

>dt1 ?
>dt2 ?
>//--------------------------------------------------------------------------

dA = B - A
dB = C - B

deriv = 2.0 * (t * dA + tval * dB)

dderiv = dB - dA

Fill in the x and y subscripts as needed. Note that for a quadratic
the second derivative is a constant vector.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Richard J Kinc » Tue, 06 May 2003 13:53:25


Quote:=MoLe= writes:
> I am building a small vinyl cutting machine,

Would like to hear more about that.
 
 
 

Quadratic Curve Derivatives help, Please

Post by =·MoLe » Tue, 06 May 2003 19:27:36






> >I am building a small vinyl cutting machine, could somebody tell me how
to
> >get the first & second derivatives of a quadratic b-spline
> >as used in a truetype font outline, below is the code used to generate
the
> >x&y points, I'm not too crash hot on math :(

> >tval  =  value of t along curve
> >A,B,C the control points.
> >//--------------------------------------------------
> >t  = 1.0 - tval
> >n1 = t * t
> >n2 = 2.0 * tval * t2
> >n3 = tval * tval

> >point_x = n1 * Ax + n2 * Bx + n3 * Cx;
> >point_y = n1 * Ay + n2 * By + n3 * Cy;

> >dt1 ?
> >dt2 ?

>//-------------------------------------------------------------------------
-

> dA = B - A
> dB = C - B

> deriv = 2.0 * (t * dA + tval * dB)

> dderiv = dB - dA

> Fill in the x and y subscripts as needed. Note that for a quadratic
> the second derivative is a constant vector.

Thanks very much for your answer , I understand that the first deriv is the
tangent vector, which is what I am trying to get, if I generate a
line between the curve point and the deriv point, shouldn't I get the
tangent line? or do I have to do something else.
I am getting a line but it's not at a tangent, although if I change the 2.0
in ( 2.0 * (t*dA+tval*dB) to a higher number, the line generated gets closer
to the expected line of tangency, please could you tell me what am I doing
wrong?

Many thanks for your reply & patience.
Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by =·MoLe » Tue, 06 May 2003 20:17:47




Quote:> =MoLe= writes:

> > I am building a small vinyl cutting machine,

> Would like to hear more about that.

Nothing special I'm afraid, just a hobby project. I'm building a small servo
driven flatbed cutter with a tangentially controlled knife.
the processor is an  8 bit rabbit 2000 and the motion control section is
based on a Xylinx Spartan II FPGA.

I want the machine to run as smooth and as fast as possible, so I am looking
at approximating curves with G1 arc segments, hopefully this
should result in a smooth toolpath, so if i sample 2 points on any curve,
get the tangent angle at each sample point I can place a BiArc span across
the sample points, and by sampling 3 or 4 intervals in between I can get the
distance from the original curve to the BiArc span and check to see if it
fits within a given tolerance, if not close the sampling interval until it
does. It does work but I wanted a more elegant method of getting the tangent
angle other than sampling two points close together. Math is *definetely*
not my forte, so I approach these things with a certain amount of
pragmatism.

Regards,
Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Ryan Farrel » Wed, 07 May 2003 01:50:45


The derivative is the tangential vector (ie direction).  The tangent
line that you're probably looking for has the direction of the
derivative but passes THROUGH THE POINT at tval.  It seems though that
you only need to know the direction that your blade should be facing
(derivative) and where the blade should be (location on curve).  Also
note that changing the coefficients won't help.

Hope that helps...
Ryan






> > >I am building a small vinyl cutting machine, could somebody tell me how
> to
> > >get the first & second derivatives of a quadratic b-spline
> > >as used in a truetype font outline, below is the code used to generate
> the
> > >x&y points, I'm not too crash hot on math :(

> > >tval  =  value of t along curve
> > >A,B,C the control points.
> > >//--------------------------------------------------
> > >t  = 1.0 - tval
> > >n1 = t * t
> > >n2 = 2.0 * tval * t2
> > >n3 = tval * tval

> > >point_x = n1 * Ax + n2 * Bx + n3 * Cx;
> > >point_y = n1 * Ay + n2 * By + n3 * Cy;

> > >dt1 ?
> > >dt2 ?

> >//-------------------------------------------------------------------------
> -

> > dA = B - A
> > dB = C - B

> > deriv = 2.0 * (t * dA + tval * dB)

> > dderiv = dB - dA

> > Fill in the x and y subscripts as needed. Note that for a quadratic
> > the second derivative is a constant vector.

> Thanks very much for your answer , I understand that the first deriv is the
> tangent vector, which is what I am trying to get, if I generate a
> line between the curve point and the deriv point, shouldn't I get the
> tangent line? or do I have to do something else.
> I am getting a line but it's not at a tangent, although if I change the 2.0
> in ( 2.0 * (t*dA+tval*dB) to a higher number, the line generated gets closer
> to the expected line of tangency, please could you tell me what am I doing
> wrong?

> Many thanks for your reply & patience.
> Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Just d' FAQ » Wed, 07 May 2003 02:57:04




Quote:>Thanks very much for your answer , I understand that the first deriv is the
>tangent vector, which is what I am trying to get, if I generate a
>line between the curve point and the deriv point, shouldn't I get the
>tangent line? or do I have to do something else.

Look carefully at your words and you will find the answer lurking. At
first you say "deriv is tangent *vector*", then you try to use it as
"deriv *point*". The tangent vector gives the *direction* of the
tangent line, not a point on it. You know the curve point is on the
line; generate a second point by adding the tangent vector to it. Or
simply use parametric line equation

  point(s) = p + s * v

where p = p(t) is the point on the curve and v = dp(t)/dt is the
tangent vector there.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Kenneth Sloa » Wed, 07 May 2003 03:26:36



Quote:> ...
> Look carefully at your words and you will find the answer lurking. At
> first you say "deriv is tangent *vector*", then you try to use it as
> "deriv *point*".

Gee...points are (a,b,c), vectors are (a,b,c) - can't you just treat
them all the same?

--

Computer and Information Sciences                       (205) 934-2213
University of Alabama at Birmingham                 FAX (205) 934-5473
Birmingham, AL 35294-1170   http://www.cis.uab.edu/info/faculty/sloan/

 
 
 

Quadratic Curve Derivatives help, Please

Post by Just d' FAQ » Wed, 07 May 2003 08:28:21




Quote:>Gee...points are (a,b,c), vectors are (a,b,c) - can't you just treat
>them all the same?

Yes, you can. However not all treatments lead to successful cures. ;-D
 
 
 

Quadratic Curve Derivatives help, Please

Post by Richard J Kinc » Wed, 07 May 2003 16:27:47


Quote:=MoLe= writes:
> Nothing special I'm afraid, just a hobby project. I'm building a small
> servo driven flatbed cutter with a tangentially controlled knife.
> the processor is an  8 bit rabbit 2000 and the motion control section
> is based on a Xylinx Spartan II FPGA.

Have you looked at, say, a Roland vinyl cutter?  They use one linear belt-
driven rail for X, grit rollers for Y motion of the material, solenoid
lifter for Z, instead of a 2D flatbed.  Simpler, less materials, more
compact, infinite Y axis.  I think you're asking for trouble if you try to
design something without a lot of experimental verification of the various
components.

What are you going to use for a knife?  The Roland cutters use a small pin
with a carbide tip clamped in a ball-bearing swivel.  The cutting edge is
just slightly offset from the swivel axis, so it just follows the tangent
on its own.  You don't need to make it a 4th axis.  They're also just a HP
plotter pen cylinder form, so you could just buy and use one.

 
 
 

Quadratic Curve Derivatives help, Please

Post by =·MoLe » Thu, 08 May 2003 16:09:59




Quote:> =MoLe= writes:

> > Nothing special I'm afraid, just a hobby project. I'm building a small
> > servo driven flatbed cutter with a tangentially controlled knife.
> > the processor is an  8 bit rabbit 2000 and the motion control section
> > is based on a Xylinx Spartan II FPGA.

> Have you looked at, say, a Roland vinyl cutter?  They use one linear belt-
> driven rail for X, grit rollers for Y motion of the material, solenoid
> lifter for Z, instead of a 2D flatbed.  Simpler, less materials, more
> compact, infinite Y axis.  I think you're asking for trouble if you try to
> design something without a lot of experimental verification of the various
> components.

> What are you going to use for a knife?  The Roland cutters use a small pin
> with a carbide tip clamped in a ball-bearing swivel.  The cutting edge is
> just slightly offset from the swivel axis, so it just follows the tangent
> on its own.  You don't need to make it a 4th axis.  They're also just a HP
> plotter pen cylinder form, so you could just buy and use one.

I used the term "vinyl cutter" to roughly describe the type of application,
I also want to cut thick card as used in picture mount boards, sand blasting
mats, silk screens etc, I am looking at the Wild,Zund & Leica cutters, they
are all flatbeds and have an infinite Y axis when using vinyl , rollers at
both ends of the machine draw the vinyl across the table surface, operating
like film in a camera. These machines have replaceable toolheads like
milling cutters,engravers,tangential knives,creasers etc, and they are
incredibly fast, but at around $25,000 they aint cheap.

"Drag knives", as you describe above don't cut sharp corners, and generally
leave nice little "C" cuts at the start of each new cut, also "weeding out"
can be a bit of a problem with complex contours.

I have already made the knife assembly, servo driven W axis and with a
pneumatic blade lifter and pusher downer :) works fine and cuts through 1/4
" card with no problems, as I say it's just a hobby project but it may turn
into something more in the future.

Regards,
Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by =·MoLe » Thu, 08 May 2003 16:21:35






> >Gee...points are (a,b,c), vectors are (a,b,c) - can't you just treat
> >them all the same?

> Yes, you can. However not all treatments lead to successful cures. ;-D

Thanks People for all your help, The above comments underline the confusion
about vectors I have, when is a vector a vector and not a line segment, as a
line segment also has a magnitude & direction, it's my understanding that a
2D Vector has 4 components

D = Vector direction in 2D Space
M = Vector Magnitude
X = X Coord of the endpoint
Y = Y Coord of the endpoint

Why would an entity with just the last two components be called a Vector?

 Another question, why is the length of a curve sometimes called its "Arc
Length" as in "Reparameterization by arc length".

Regards,
Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Hans-Bernhard Broeke » Thu, 08 May 2003 19:03:16


[..."point" vs. "vector"]

Quote:> Thanks People for all your help, The above comments underline the confusion
> about vectors I have, when is a vector a vector and not a line segment,

A vector is _never_ a line segment.

Quote:> as a line segment also has a magnitude & direction, it's my
> understanding that a 2D Vector has 4 components
> D = Vector direction in 2D Space
> M = Vector Magnitude
> X = X Coord of the endpoint
> Y = Y Coord of the endpoint

_No_.  A 2D vector has no particular endpoint.  It has only a
direction and magnitude.  

Or, as the mathematicians would put it: it's the equivalence class of
all directed line segments that are parallel to each other, are
oriented the same way (regarding start and end points), and have the
same length.  An individual oriented line segment can be thought of as
a "representative" of this infinite set of equivalent edges that, as a
collection, define the "vector".  But it "is" not a vector, on its
own.

What you're describing really is an (oriented) line segment.  That's
the a perfectly fine name for this thing, so why should anyone want to
waste another name for the same thing?

Quote:> Why would an entity with just the last two components be called a Vector?

Because it isn't.  An entity with just the last two of those
components is called a _point_.  Rather an entity with just the
_first_ two of your components defined would really be a vector.

And no, a point is not the same thing as a vector.  There is a rather
strong relationship between the two, since every point can be
constructed as a vector added to a fixed coordinate origin point, but
that does *not* make them the same thing.

The difference shows up when you ask what the "zero" vector or point
is.  For vectors, that absolutely well-defined: the vector of length
zero.  For points, it's not defined at all: there is no particular
point that deserves to be called the "zero point" or "origin" any more
than all the others.

Quote:>  Another question, why is the length of a curve sometimes called its "Arc
> Length"

No particular reason --- other than "arc" being just a bit easier to
type than "curve".
--

Even if all the snow were burnt, ashes would remain.
 
 
 

Quadratic Curve Derivatives help, Please

Post by =·MoLe » Thu, 08 May 2003 20:41:29




> [..."point" vs. "vector"]

> > Thanks People for all your help, The above comments underline the
confusion
> > about vectors I have, when is a vector a vector and not a line segment,

> A vector is _never_ a line segment.

> > as a line segment also has a magnitude & direction, it's my
> > understanding that a 2D Vector has 4 components

> > D = Vector direction in 2D Space
> > M = Vector Magnitude
> > X = X Coord of the endpoint
> > Y = Y Coord of the endpoint

> _No_.  A 2D vector has no particular endpoint.  It has only a
> direction and magnitude.

> Or, as the mathematicians would put it: it's the equivalence class of
> all directed line segments that are parallel to each other, are
> oriented the same way (regarding start and end points), and have the
> same length.  An individual oriented line segment can be thought of as
> a "representative" of this infinite set of equivalent edges that, as a
> collection, define the "vector".  But it "is" not a vector, on its
> own.

> What you're describing really is an (oriented) line segment.  That's
> the a perfectly fine name for this thing, so why should anyone want to
> waste another name for the same thing?

> > Why would an entity with just the last two components be called a
Vector?

> Because it isn't.  An entity with just the last two of those
> components is called a _point_.  Rather an entity with just the
> _first_ two of your components defined would really be a vector.

> And no, a point is not the same thing as a vector.  There is a rather
> strong relationship between the two, since every point can be
> constructed as a vector added to a fixed coordinate origin point, but
> that does *not* make them the same thing.

> The difference shows up when you ask what the "zero" vector or point
> is.  For vectors, that absolutely well-defined: the vector of length
> zero.  For points, it's not defined at all: there is no particular
> point that deserves to be called the "zero point" or "origin" any more
> than all the others.

> >  Another question, why is the length of a curve sometimes called its
"Arc
> > Length"

> No particular reason --- other than "arc" being just a bit easier to
> type than "curve".
> --

> Even if all the snow were burnt, ashes would remain.

Thanks for your reply to these questions, you have lifted a veil of opacity
for me :) Many thanks.

Martin.

 
 
 

Quadratic Curve Derivatives help, Please

Post by Just d' FAQ » Fri, 09 May 2003 04:34:17


Ken Sloan and I were having a private joke here, because this issue of
point versus vector has come up time and again, with some folks saying
it's convenient to not distinguish them, and others of us saying that
that leads to confusion and mistakes. Your example is a vote for the
latter position, which happens to be my own.

Whatever the source of your graphics education, it looks like you've
got a muddled collection of concepts. None of what you "understand" is
accurate! Let's try to correct that, briefly.

POINT. Whether on a line, in a plane, in 3D space, or whatever, we
think of a point as something without length, width, height, or any
other dimension; just a placeholder at a particular position.

VECTOR. We think of these as displacements from one point to another,
translating the entire space of points. Vectors do have magnitude
(length) and direction, unlike points themselves. There is also a
distinguished "null" or zero-magnitude vector. We can add vectors, and
stretch and shrink (scale) them. Adding vectors means we combine their
displacements. We can also "add" a vector to a point, meaning we are
displacing the point. And it is convenient to say we "subtract" two
points to get the vector that displaces one to the other. But a vector
has no position in the same sense a point does.

LINE. Take a point and a vector, and displace that point by all
possible scaled versions of that vector to get an infinite collection
of points. Those points form a line. A line does have a position, but
unlike the generating vector it does not have a direction. Remember we
keep only the points, not the generators. (And any number of different
points and vectors can generate the same line.) However, ...

DIRECTED LINE. This is a more sophisticated concept, because along
with the points of a line we have an ordering. Given two distinct
points on the line we can say "this one comes before that one".

LINE SEGMENT. Snip off a piece of a line; or limit the scaling of the
generating vector for the same effect. A line segment has a position
and a length, but again no direction. However, ...

DIRECTED LINE SEGMENT. This collection of points is ordered, so we can
say it goes from this end to that end, not the other way around. Thus
a directed line segment has position, length, and direction. We can
generate it using the point at one end and the vector from that to the
other end.

OPPORTUNITY FOR CONFUSION: If a point is *assumed* (such as the origin
of a coordinate system for a plane) a vector implies any of the other
constructs! Displace the origin to get a point, displace scaled to get
a line, preserve direction to get directed line, and so on.

But a tank of gas is not a town, even though it may power a vehicle to
get you from one town to another.







>> >Gee...points are (a,b,c), vectors are (a,b,c) - can't you just treat
>> >them all the same?

>> Yes, you can. However not all treatments lead to successful cures. ;-D

>Thanks People for all your help, The above comments underline the confusion
>about vectors I have, when is a vector a vector and not a line segment, as a
>line segment also has a magnitude & direction, it's my understanding that a
>2D Vector has 4 components

>D = Vector direction in 2D Space
>M = Vector Magnitude
>X = X Coord of the endpoint
>Y = Y Coord of the endpoint

>Why would an entity with just the last two components be called a Vector?