Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to check whether the curve is concave?

Subject: How to check whether the curve is concave?

From: Marco Wu

Date: 3 Oct, 2011 16:33:26

Message: 1 of 7

Dear all,

 I have a polar coordinate equation, I want to see whether the data points from that equation will be concave in XY plane.

 My Current method is using 2nd derivative method on the polar coordinate equation; and check the maximum value is less than zero with an angle range . HOWEVER, I am not sure this method is right.

 I want to use XY coordinates to test it, but I will not have a simple equation for that. So would it be possible to do it in points base?? If yes, how I should use my XY points to tell whether the curve is concave?

Thanks

Subject: How to check whether the curve is concave?

From: someone

Date: 3 Oct, 2011 18:41:42

Message: 2 of 7

"Marco Wu" wrote in message <j6co4m$21q$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I have a polar coordinate equation, I want to see whether the data points from that equation will be concave in XY plane.
>
> My Current method is using 2nd derivative method on the polar coordinate equation; and check the maximum value is less than zero with an angle range . HOWEVER, I am not sure this method is right.
>
> I want to use XY coordinates to test it, but I will not have a simple equation for that. So would it be possible to do it in points base?? If yes, how I should use my XY points to tell whether the curve is concave?
>
> Thanks

doc pol2cart

[X,Y] = pol2cart(THETA,RHO)

transforms the polar coordinate data stored in corresponding elements of THETA and RHO to two-dimensional Cartesian, or xy, coordinates. The arrays THETA and RHO must
be the same size (or either can be scalar). The values in THETA must be in radians.

Now use your "2nd derivative method" on the xy data.

Subject: How to check whether the curve is concave?

From: Marco Wu

Date: 3 Oct, 2011 18:54:16

Message: 3 of 7

But it seems like you ignore the fact that there could be more than one Y value for the same X, if I convert the pol2cart coordinate. The 2nd order derivative should only work for unique Y value for giving any given X.

Subject: How to check whether the curve is concave?

From: Matt J

Date: 3 Oct, 2011 19:17:31

Message: 4 of 7

"Marco Wu" wrote in message <j6d0co$2qn$1@newscl01ah.mathworks.com>...
> But it seems like you ignore the fact that there could be more than one Y value for the same X, if I convert the pol2cart coordinate. The 2nd order derivative should only work for unique Y value for giving any given X.
==================

If you have a series of X,Y points on the curve, then you can find their convex hull in inequality form

A*x<=b

using this tool

http://www.mathworks.com/matlabcentral/fileexchange/30892-representing-polyhedral-convex-hulls-by-vertices-or-inequalities

Using the inequalities, you can also test how close each point is to the boundary of the convex hull. If all X,Y are within some tolerance of the boundary, you can conclude concavity/convexity.

Subject: How to check whether the curve is concave?

From: someone

Date: 3 Oct, 2011 19:24:27

Message: 5 of 7

"Marco Wu" wrote in message <j6d0co$2qn$1@newscl01ah.mathworks.com>...
> But it seems like you ignore the fact that there could be more than one Y value for the same X, if I convert the pol2cart coordinate. The 2nd order derivative should only work for unique Y value for giving any given X.

How do you get multiple y values?
Since pol2cart uses the atan2 function, its not obvious to me.
Are there multiple r, theta values in your data?
Or am I missing something?

Subject: How to check whether the curve is concave?

From: FDR

Date: 18 Nov, 2011 22:18:11

Message: 6 of 7

"Marco Wu" wrote in message <j6d0co$2qn$1@newscl01ah.mathworks.com>...
> But it seems like you ignore the fact that there could be more than one Y value for the same X, if I convert the pol2cart coordinate. The 2nd order derivative should only work for unique Y value for giving any given X.


I don't know if this will be of any use, but I just submitted a file that checks convexity/concavity of a data set. It doesn't handle very large data sets (yet), but if you want to take < 100 sample points and verify their convexity/concavity within a tolerance (probably very small tolerance if you assume no noise), then it might do what you want.

http://www.mathworks.com/matlabcentral/fileexchange/33811

The convex hull approach is probably not that bad, either, though.

Subject: How to check whether the curve is concave?

From: Roger Stafford

Date: 19 Nov, 2011 03:19:13

Message: 7 of 7

"Marco Wu" wrote in message <j6co4m$21q$1@newscl01ah.mathworks.com>...
> I have a polar coordinate equation, I want to see whether the data points from that equation will be concave in XY plane.
- - - - - - - - - -
  Marco, I can't tell from your statement what form your polar coordinate equation is in. The following may or may not be useful to you.

  Let a curve be defined in polar coordinates with the polar distance r and the polar angle t (short for theta) both being determined as functions of some parameter s. Let the first derivatives of r and t with respect to s be denoted by r' and t', and their second derivatives by r" and t". Then the curvature of the curve is given by the formula:

 K = (-r*r"*t'+r^2*t'^3+2*r'^2*t'+r*r'*t")/(r'^2+r^2*t'^2)^(3/2)

where as s increases a positive value indicates a curvature to the left and negative a curvature to the right. You can then determine "concavity" or "convexity" by merely checking the sign of the numerator since the denominator is always positive. You will note that there is no reference here to cartesian coordinates.

  In case your equation has r as a function of t, then t itself could be considered as the parameter s in the above formula, or with t a function of r, then r would be the parameter. If you have an implicit equation in r and t, then perhaps the above does not help unless you can solve for one or the other of these variables or unless some parametric representation of the curve occurs to you.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us