15,608,553 members
See more:
Hello

I have a need to generate a set of curves which are completely novel. I am looking for both, the mathematical solution and programing/graphic solution to produce the visual end product. Any programing/graphic solution/language will be fine and 1000% better than what I have now but ultimately I would like to utilize it in CAD/CADD/CAE. (Did I say that right? I know nothing of programing nor its lingo so I probably sound like a dunce. I will have to get help with that from someone locally. :^D )

NOTE:
The following is only one specific example/scenario for simplified discussion purposes. Other scenarios are generated by altering the parameters but are not considered here.

NOTE 2: VERY IMPORTANT!!!

Definitions:

ROTATE/SPIN: to cause to turn on an axis, shaft, or center, like a gear. This is the movement considered/used here.

REVOLUTION: turning of an object which can be either axial or orbital. Only axial revolution/movement is considered here.

ORBIT: path described by one a body in its revolution about another, like Earth around the sun.(Movement NOT used here)

TRANSLATION: movement that changes the position of an object, as opposed to rotation. (Movement NOT used here)

My definition of FIXED IN SPACE: without TRANSLATIONAL or ORBITING movement. Only ROTATION/REVOLUTION movement of object on its axis occurs, like a gear.

NOTE 3:
For those unfamiliar with cycloids, please see animated examples here: http://en.wikipedia.org/wiki/Epicycloid[^] and here http://en.wikipedia.org/wiki/Hypotrochoid[^] This is similar to the solution I seek (two circles carrying out some motion0 EXCEPT there is no translational movement of the small inner circle(it only rotates/spins in place) AND the large outer circle also only rotates/spins in place on its own axis.

NOTE 4:
Please take a look at these sun gear pictures. It is very similar to one of my solutions which after many revolutions would produce multiple teeth. But, because my problem calls for slippage at the point of contact (no teeth engaging), the resulting curve trace will be novel.
http://prius.ecrostech.com/original/Understanding/PowerSplitDevice.htm[^]

My scenario consists of 2 circular curves (circles). The smaller one is located inside the larger circle and in contact at one point. For convenience, let this point be at the "12o'clock" position. Set the size of the smaller circle at 75% of the larger circle and set the rotational velocity of BOTH element's/circle's axis/shafts at 1 rpm WITHOUT any orbiting/translational movement. They will simply spin/rotate in place on their respective axis/shafts which are FIXED IN SPACE (like a vane pump whose casing also rotates on its own axis, or like the ring gear and one planet gear in a sun/planetary gear set but WITHOUT the teeth meshing/engaging [please consider/think off/look at only the ring and the one top planet gear sized to 75% of the ring gear!!!!!!]) and will have different/differential circumferencial velocities. This difference in circumference velocities along with the centers/axis/shafts not being coincident (not the same point[2 different axis/shafts!!!]), their original points of contact (which started at 12o'clock in this specific scenario) will have a translation with respect to each other whose trace in one rotation is a curve that probably resembles an ellipse/football/rugby ball or even a tear drop pointing inward towards the center like in a ring gear http://www.gasgoo.com/auto-products/processing-parts-mould-302/1059482.html[^] whereas the points of a hypocycloid curve point from the center of the circle outward and touch the outer circle somewhere along its circumference with the tips. An example of hypocycloid can be seen here http://en.wikipedia.org/wiki/File:Hypocycloid-4.svg[^] Other scenarios with multiple rotations will produce multiple inward pointing ellipses/teeth/rays like a stylized sun with rays pointing inward, not outward. One such example of inward pointing rays would be the inverse/opposite(?) of http://en.wikipedia.org/wiki/File:Hypocycloid-7-2.svg[^] )
The parent page is http://en.wikipedia.org/wiki/Hypocycloid[^]

Another way to analyze this is geometrically.
Let point A lie on the large circle and point B on the small circle located such that they are touching at time zero at the 12o'clock position. Connect A & B with a straight segment which terminates at the axis of the large circle and call this point C. After rotating both circles 90 degrees clockwise, in order for the line to connect A-C it has to pass through B which is clearly above A and C. The line has to either sharply bend at B or gradually curve to achieve this. Since this is a continuous motion and not stepped progression, the line segment A-B had to go through a gradual bending as it passed through B - a curve. After 180 degrees of rotation, points A, B, and C will be in line again. This is the trace of half of the curve. It resembles an arc of a circle or exponential curve. The other 180 degrees of rotation should produce a mirror trace which now I think might look like an ELLIPSE with pointed ends, like an American football or rugby ball or perhaps a tear drop. If it turns out that the first 180 degrees of rotation is not a smooth curve but rather two straight segments joined at a kink, then the complete curve might look like a rhombus http://janbrett.com/games/jan_brett_geometric_shapes_diamond.htm[^] or a kite http://en.wikipedia.org/wiki/Kite_%28geometry%29[^]

Another way of saying all of the above is like this. It is a trace of a point on the circumference of the smaller inner rotating circle with respect to the moving point on the circumference of the larger rotating circle without any translation of the circles. The circles only spin on their respective axis while generating this curve.

Various differential speeds and various sizes of circles will create different curves(solutions). Other scenarios, such as epicycloidal arrangement, or other circular curves (ellipses) will produce yet other solutions.

THE CHALLENGE:
As far as I can tell, no such curves have ever been produced and I have not been able to create the curves effectively. I've approximated the curve in my example but it appears I was wrong. I seek a precise solution and hopefully a graphic or animated representation. There is a lot of talent here and it seems that the CodeProject is a perfect place to find resolution to my problem. Your input would be of great assistance. A solution in any programing language will suffice but ultimately I would like to utilize it in CAD/CADD/CAE. If this is not the correct forum for the mathematical solution, any input pointing in the correct direction would also be greatly appreciated.

Thank in advance and I look forward to hearing from you.

Best regards
Milan Kroupa

P.S.
I came across this website in search of the solution to one of my problem and landed in page "Spirograph Shapes: WPF Bezier Shapes from Math Formulae" by KenJohnson which can be found here Spirograph Shapes: WPF Bezier Shapes from Math Formulae[^]. I was hoping to engage him or his forum although it now appears that there is a LOT of talent capable of this tackling this challenge.

I may have posted my question inappropriately as I've never participated in forum such as this and am having difficulty understanding and navigating in it. Thank you for your help and patience.

Peace.
***
Posted
Updated 22-Mar-12 11:34am
v15
TRK3 16-Mar-12 18:09pm
What exactly are you trying to do? And what have you attempted?

It's not clear what you mean when you say "generate a set of curves"...

Mathematically that would mean write down an equation.

To a graphic designer that would mean draw a curve on the screen.

Which do you want? And it what language / graphics system? Specifying both C++ and Javascript makes you sound like you have no idea what you are doing.

Also, you say "...WITHOUT any orbiting/translational movement. They will simply spin in place.."

If there is no orbiting/translational movement with the circles just spinning in place, then there will only be one point of contact -- the original one -- and it won't move or describe any new curve.

Also, what is it that describes the curve? Not the point of contact.

I think you really mean that there is orbital and translational movement (which you still haven't specified exactly in your description) and the curve you are trying to describe is the curve described by a specific point on the inner circle (NOT the point of continuous contact).

The very first thing you need to learn in programming is that you need to be able to clearly and precisely specify what it is that you are trying to program. If you can't do that, it's impossible to program -- or at least impossible to say that whatever you did program is correct.
Member 8736093 19-Mar-12 17:40pm

You are correct about my sounding like a novice to programing and a dunce in my communication but please see my updated question which, hopefully, clarifies my previous miscommunication. (working 16/7 induces me to be brief. I apologize for my undue brevity and imprecision. To boot, English is my 3rd language, originally Czech born. Still learning its mastery.)

To clarify, you are correct when you say "...Also, what is it that describes the curve? Not the point of contact." As is true for any plot of plane curves that are produced by rotating/orbiting circles, it is the relative motion of the original points of contact that describe/trace/plot these new curves.

Thank you again for your input.
TRK3 19-Mar-12 18:09pm
I'm still not clear on what you are asking.

If the two original circles just spin in place, then the original points of contact simply describe two circles when they spin.

When you say the "relative motion" of the two points, what is it you are the plotting? A two dimmensional plot of distance vs time?

Or are you plotting the position (distance and angular displacement)of one in the frame of reference of the other (irrespective of time)?

In either case, Jack Dingler's solution is a good way to go about it and relatively easy.

Is that what you are looking for?
Member 8736093 19-Mar-12 22:25pm
Right you are again TRK3

I believe it is a form of hypocycloid plane curve I seek. Please see my updated question which includes few links to animated cycloids which should substantially clarify my question (I hope :^D ). Jack Dingler's approach is good but I am unable to do anything with it. Calculating the formula is beyond me and implementing it in a software for visual representation is doubly impossible for me.

Please see my updated question so that you may better comprehend the question.

Cheers.

***
Sergey Alexandrovich Kryukov 16-Mar-12 23:06pm
Not a question. "I have not been able..." is not informative.
What is the problem? It is mathematics or something else?
--SA

## Solution 3

Ok, I think that I now know what you mean. Let me repeat it in my words, so you can cross check that I have understood your goal. We have two wheels (circles) mounted with their axels in different positions and touching each other at the 12 o'clock point. Both rotate with 1 rpm. On each wheel you have a designated point at the circumference. At first, both points are in the 12 o'clock position and hence they coincide. As rotation starts they will move apart. What you want to draw is the position of the point on the inner wheel in relation to the point on the outer wheel and that for all rotational angles of the wheels. Correct?

Now here would be a little piece of C++ code that computes these relative position and puts them in an array:
```double px [1000];
double py [1000];
const double r1 = 1.0;               // radius of first circle
const double r2 = 0.75;              // radius of second circle
const double cx1 = 0.0, cy1 = 0.0;   // center of first circle
const double cx2 = 0.0, cy2 = 0.25;  // center of second circle
const double PI = 3.14159265;

// divide a full rotation into 1000 steps, each is hence (2 PI / 1000) radians
for (int idx = 0; idx < 1000; ++idx)
{
double angle = idx * PI / 500. + 0.5 * PI;

// calculate point1 for that step
double x1 = r1 * cos (angle) + cx1;
double y1 = r1 * sin (angle) + cy1;

// calculate point2 for that step
double x2 = r2 * cos (angle) + cx1;
double y2 = r2 * sin (angle) + cy1;

// subtract these points from each other and assign them
// to the arrays
px[idx] = x2 - x1;
py[idx] = y2 - y1;
}```

Without question that little piece of code could have been done more elegant, but I wanted it to be as simple as possible. Now having the two arrays you can visualize them in a window, print them in a list or whatever. That would be a second part to the problem. If you want to experiment with these curves, I would recommend that you get familiar with the Python language and the Spider Framework. They are easy to learn and extremely helpful when doing this kind of experiments. Of course they are free and you find them easily via google or on

If I still misunderstood the problem don't hesitate to add more details to your original question. The reason for having doubts is that the above code produces a circle as result (as Stephan_Lang aready mentioned in his comment). Adding or subtracting circular functions (that have the same frequency) from each other will again produce circles. But perhaps you want to start with that model and than start tweeking with the rotation speeds etc.

I hope this little code snippet helps you a little further along the way.

v7
Member 8736093 19-Mar-12 22:42pm
I have updated my question nv3 and look forward to your input.

Milan K.
Member 8736093 21-Mar-12 1:41am
+++

nv3, it seems your verbal analysis is on the money!!! I have updated my question for the 8th time. See if your thoughts resonate with mine. :^D

Although I know nothing of programing, I can deduce the function of most of the steps and looking at line 6 (bellow) I believe cy2 should be equal to .75/2 = .375
const double cx2 = 0.0, cy2 = 0.25; // center of second circle

So you think the result is a circle? My guesstimate of an ellipse might be close then. Do people here give second opinions or is that bad etiquette? This solution is very, very important to me.

What do I do with the code? Plot it? I have no clue. %-D
How can I get a visual animated representation/solution?

Thank you for your efforts so far. :-D I've plodded over this for past 4 days on this site.

Cheers.

***
nv3 21-Mar-12 5:49am
I have updated the Python link, the http:// was missing. It will take you some time to digest all the possibilities of that tool, but for a non-programmer i think its a great instrument to experiment and to draw diagrams. Take a look at the Mathplot library that comes with the installer.

Regarding the center of the second circle: The bigger circle has a radius of 1.0, the smaller one 0.75. Hence we must move the center of the smaller circle by 0.25 in y-direction to make the circles touch in the 12 o'clock position, don't we?

The resulting curve will be a circle and that is easy to prove: Imagine the case in which the centers of both circles are identical. In this case it's easy to see that the result is a circle. Now, in our case the center of the second circle is just shifted upward by 0.25. Hence all result points will also be shifted for this constant offset, and hence the result will again be a circle. In fact, as long as both circles rotate with the same angular speed, the result will always be a circle, not matter what the center shift or difference in radius is.

Stefan_Lang 22-Mar-12 9:24am
Now that I, too, realize, that what you wanted is the trace of the difference of the two points, I have to agree with the findings of this solution, including the conclusion that it has to be a circle. If you plot it however, you will notice it is not a circle around (0,0), but around (0,0.25), with a radius of 0.25.

You'll get more interesting results if you let the circles rotate at differing speeds. E. g. if the inner circle rotates at double speed, you'll get something that looks like a sideways '8', with the right-hand loop a lot smaller and folded to the left, inside the left-hand loop.

If you choose a factor that is not a whole number, you'll get something that looks a lot like hypocycloids, but I haven't bothered to check if they're actually the same.

Perhaps it would be a good idea to pick up some easy-going proggramming language with drawing facility and experiment a bit. Python is definitiely a good suggestion for this purpose, I have to agree with nv3 about that.
Member 8736093 22-Mar-12 18:20pm
+++

Well, that is very encouraging, Stefan. Thank you for your input. It made my day.

I was hoping to find the curve with respect to (0,0). This solution poses a problem for me. I can't use it. How can this be remedied?

Unfortunately learning programing at my age and present state( which it not good) is not an option. I barely get any sleep as is. Recently I have been working on solving the question of "What is gravity" and how to use it to do work, including propulsion in all media[on land, in water, air, and space]. I think I made a major breakthrough last night. I'll confer with a few colleagues today.

Gravity is not what the mainstream science thinks it is. If you are interested in this subject read up on "aether theory" although that is not the complete picture.

Danke vielmal für deine Hilfe, Stefan und nv3.

***

## Solution 4

I'm really afraid my help could be not very useful. I'm presenting a complete solution based on .NET and C#. The problem is way too simple: just a combination of two rotations. If you did not know how to calculate that, I would afraid just using the code would also be a problem. Anyway, let's try.

First of all, define a floating-point type to work with and a 2D vector with just a vector sum:

C#
```using Real = System.Double;

//...

public struct Vector2d {
public Vector2d(Real x, Real y) { this.x = x; this.y = y; }
public static Vector2d operator +(Vector2d left, Vector2d right) {
return new Vector2d(left.X + right.X, left.Y + right.Y);
} //operatior +
public Real X { get { return x; } }
public Real Y { get { return y; } }
Real x, y;
} //Vector2d```

Now, define rotation, and only around the center {0, 0}. We will need to translate the coordinate system (using '+' defined above) anyway when we sum the rotations.
C#
```public class Rotation { //around {0, 0}

public Rotation(Real radius, Real angularVelocity, Real phase) { Initialize(radius, angularVelocity, phase); }

public Vector2d GetPosition(Real time) {
return new Vector2d(
radius * System.Math.Cos(time * angularVelocity + initialPhase),
radius * System.Math.Sin(time * angularVelocity + initialPhase));
} //GetPosition

void Initialize(Real radius, Real angularVelocity, Real phase) {
this.angularVelocity = angularVelocity;
this.initialPhase = phase;
} //Initialize

} //Rotation
```

Now, I'm going to define the complex motion. Instead of definition of just two rotations, I'll define the hierarchy of unlimited rotating coordinate system: one rotation defines the center of another coordinate system, that one is also rotating, etc. In you case you will use just the array of two elements, one representing a main circle, another one — a planetary circle. So, this one will represent the hierarchy of unlimited members:
C#
```public class ComplexRotationCalculator {

public ComplexRotationCalculator(Vector2d center, params Rotation[] systems) {
this.center = center;
this.systems = systems;
} //ComplexRotationCalculator
public ComplexRotationCalculator(params Rotation[] systems) {
this.center = new Vector2d(0, 0);
this.systems = systems;
} //ComplexRotationCalculator

public Vector2d GetPosition(Real time) {
Vector2d result = center;
foreach(Rotation rotation in systems)
result += rotation.GetPosition(time); //shift of coordinate
return result;
} //GetPosition

public Vector2d[] GetTrajectory(Real step, uint pointNumber) {
Vector2d[] trajectory = new Vector2d[pointNumber];
for (uint index = 0; index < pointNumber; ++index)
trajectory[index] = GetPosition(index * step);
return trajectory;
} //GetTrajectory
return trajectory;
} //GetTrajectory

Vector2d center;
Rotation[] systems;

} //public class ComplexRotationCalculator```

Basically, that's it. You can use the final `GetPosition` for rendering graphics immediately, or generate an array of points via `GetTrajectory`. This trajectory can be later imported anywhere to make the picture. I suggest to forget all the interpolations we discussed and just generate points with the step which is small enough to give an accurate picture. The speed of calculation is very high, so you can calculate many thousands of points without virtually any wait.

Let's show, for example, how to render with `System.Graphics`, which can be used along or with `System.Drawing.Forms` or anything like that. Let's add the namespace and the function calculating the trajectory in terms of points defined in this library:
C#
```using System.Drawing;

//...

public class ComplexRotationCalculator {

//...

public System.Drawing.PointF[] GetPointTrajectory(Real step, uint pointNumber) {
System.Drawing.PointF[] trajectory = new System.Drawing.PointF[pointNumber];
for (uint index = 0; index < pointNumber; ++index) {
Vector2d vector = GetPosition(index * step);
trajectory[index] = new System.Drawing.PointF(
(float)vector.X,
(float)vector.Y);
} //loop
return trajectory;
} //GetPointTrajectory

} //public class ComplexRotationCalculator```

Again, this rendering can be used immediately to show the rendered graphics on screen in the handle of the event `Paint` or, better yet, overridden method `OnPaint` of some control. For simplicity, I'll show rendering of some bitmap and saving it to a file:

C#
```class Sample {

static void RenderTrajectory(Graphics graphics, Pen pen, PointF[] trajectory) {
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.DrawLines(pen, trajectory);
} //RenderTrajectory

static void RenderTrajectoryBitmap(Pen pen, int width, int heigh, string filename, PointF[] trajectory) {
Bitmap bitmap = new Bitmap(width, heigh, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
RenderTrajectory(Graphics.FromImage(bitmap), pen, trajectory);
bitmap.Save(filename);
} //RenderTrajectoryBitmap

// this is a realistic sample which shows some trajectory with sufficient quality
// and enough room in the bitmap to fit the curve:
public void Run() {
ComplexRotationCalculator calc = new ComplexRotationCalculator(
new Vector2d(300, 300),
new Rotation[] { new Rotation(200d, 1d), new Rotation(30d, 16d), });
PointF[] trajectory = calc.GetPointTrajectory(0.001, 36000);
RenderTrajectoryBitmap(Pens.White, 600, 600, "test.png", trajectory);
} //Run

} //class Sample
```

For further detail of rendering using `System.Drawing` and `System.Windows.Forms`, please see my past answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^].

http://msdn.microsoft.com/en-us/library/ms747393.aspx[^].

—SA

v3
Member 8736093 26-Mar-12 14:58pm
Wow, SAKryukov.
That looks impressive especially given that it can generate graphics. I'll have to get someone here to implement it for me.

Thank you for all your time and effort. Its greatly, greatly appreciated. My project could not have moved ahead without it. Its not easy to do a project with zero budget (no money).

P.S.
Where are you? I live part time California and part time in Montana taking care of my 80 year old mother.
Sergey Alexandrovich Kryukov 26-Mar-12 17:10pm
You are welcome.
I'm in Massachussetts.
--SA

## Solution 1

Apart from the outer circle turning and the claim that both circles stay in place (which is impossible), this site may be helpful:
http://mathworld.wolfram.com/Hypocycloid.html[^]

Member 8736093 19-Mar-12 17:59pm
Danke/Thank you for your input Stefan.

I've been to that link previously yet it does not address my problem.

It is true that both circles can, and in this application MUST, rotate on their own axis. (See vane pumps). In vane pumps, there is motion of the inner circle relative to the outer circle, the stator/body/cylinder, without translation, which, unfortunately, produces friction yet these mechanisms are in wide use.

Thank you again, Stefan.

## Solution 2

1. Implement a formula for calculating the points according to time. Time can just be a double precision number as a representation. No need to use a time/date format for calculations. Your time will likely get converted to an angle, for sine cosine functions to use.
2. Starting at zero, iterate through some interval of time to the limit, you wish to stop at.
3. Draw a line from the last point to the next point to approximate curves.
4. For an optimization, don't draw a line if the two end points are the same.

Member 8736093 20-Mar-12 3:24am
Hello Jack

You are correct. I wish to implement/create a formula for this system of spinning circles. Being circles, the use of sine, cosine, and angles would yield the simplest solution.

For you, it is as simple as 1, 2, 3, 4. For me, having been out of school 35 years, it is next to impossible to undertake. It would be like asking a Neanderthal to invent a computer. :^D

Care to read my updated question and help this Neanderthal?