新颖的曲线生成项目 [英] Novel curves generation project

查看:83
本文介绍了新颖的曲线生成项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我需要生成一组完全新颖的曲线.我正在寻找产生视觉最终产品的数学解决方案和编程/图形解决方案.任何编程/图形解决方案/语言都可以,并且比我现在拥有的要好1000%,但最终我希望在CAD/CADD/CAE中使用它. (我说的对吗?我不了解编程或它的术语,所以我听起来好像很笨拙.我将不得不从本地人那里获得帮助.:^ D)

注意:
以下仅为简化讨论目的的一个特定示例/场景.其他情况是通过更改参数生成的,但此处未考虑.


注意2:非常重要!!!

定义:

旋转/旋转:使齿轮,齿轮或轴在轴,轴或中心上旋转.这是此处考虑/使用的机芯.

旋转:转动可以是轴向或轨道的物体.这里仅考虑轴向旋转/运动.

ORBIT:一个物体围绕另一个物体旋转所描述的路径,例如围绕太阳的地球.(此处未使用运动)

翻译:改变物体位置而不是旋转的运动. (此处未使用运动)

我对在空间中固定"的定义:没有翻译或绕行运动.像齿轮一样,仅发生对象在其轴上的旋转/旋转运动.


注意3:
对于那些不熟悉摆线的人,请在此处查看动画示例: http://en.wikipedia.org/wiki/Epicycloid [ ^ ]和此处http://en.wikipedia.org/wiki/Hypotrochoid [ http://www.orientalmotor.com/newsletter/PN-Geared.htm [ ^ ]
http://prius.ecrostech.com/original/Understanding/PowerSplitDevice.htm [ ^ ]


我的场景由2条圆形曲线(圆形)组成.较小的一个位于较大的圆内,并在某一点接触.为了方便起见,将这一点设置在"12点钟"位置.将小圆的大小设置为大圆的75%,并将BOTH元件/圆的轴/轴的旋转速度设置为1 rpm,而无需进行任何轨道/平移运动.它们只需在固定在空间中的相应轴/轴上旋转/旋转就位(例如叶片泵的外壳也沿其自身轴旋转,或者像太阳/行星齿轮组中的齿圈和一个行星齿轮,但在没有齿啮合/啮合的情况下[请考虑/想一想/仅看一下齿圈和一个最大行星齿轮,其尺寸为齿圈的75%!!!!]),并且圆周速度会有所不同.圆周速度的这种差异以及中心/轴/轴的不一致(不是同一点[2个不同的轴/轴!!]),它们的原始接触点(在此特定情况下从12点开始) )彼此之间有一个平移,其旋转一圈的轨迹是一条曲线,可能类似于椭圆形/橄榄球/橄榄球或什至是像环形齿轮那样向内指向内的泪滴http://www.gasgoo.com/auto-products/processing-parts-mould-302/1059482.html [^ ],而下摆线曲线的点从圆心向外指向,并用尖端沿外圆周接触外圆.摆线的一个例子可以在这里看到 http://en.wikipedia.org/wiki/File:Hypocycloid- 4.svg [ ^ ]其他具有多次旋转的场景将产生多个向内指向的椭圆/牙齿/射线,例如风格化的太阳,且射线指向内部而不是向外.向内指向射线的此类示例之一是 http://en .wikipedia.org/wiki/File:Hypocycloid-7-2.svg [ ^ ])
父页面是 http://en.wikipedia.org/wiki/Hypocycloid [ http://janbrett.com/games/jan_brett_geometric_shapes_diamond.htm [ http://en.wikipedia.org/wiki/Kite_ %28geometry%29 [^ ]

上面所有这些的另一种说法是这样的.它是较小的内部旋转圆的圆周上的点相对于较大旋转圆的圆周上的移动点的痕迹,而圆没有任何平移.圆在生成此曲线时仅在其各自的轴上旋转.

各种不同的速度和各种大小的圆将创建不同的曲线(解).其他情况,例如上摆线排列或其他圆形曲线(椭圆)将产生其他解决方案.

挑战:
据我所知,还没有产生这样的曲线,我也无法有效地创建曲线.我已经在示例中对曲线进行了近似,但是看来我错了.我寻求一种精确的解决方案,并希望以图形或动画形式呈现.这里有很多人才,似乎CodeProject是找到解决我的问题的理想场所.您的意见将为您提供很大的帮助.任何编程语言的解决方案都已足够,但最终我想在CAD/CADD/CAE中使用它.如果这不是数学解决方案的正确论坛,那么也将不胜感激任何指向正确方向的输入.

在此先感谢您,我们期待收到您的来信.


最好的问候
米兰·克鲁帕


P.S.
我在这个网站上找到了我的一个问题的解决方案,并进入了KenJohnson撰写的页面"Spirograph Shapes:来自Math Formulae的WPF Bezier Shapes",可以在以下页面中找到

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://www.orientalmotor.com/newsletter/PN-Geared.htm[^]
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.
***

推荐答案

好,我想我现在知道您的意思了.让我用我的话重复一遍,以便您能交叉核对我是否了解您的目标.我们有两个轮子(圆),它们的轮轴安装在不同的位置,并且在12点钟位置相互接触.两者均以1 rpm的速度旋转.在每个车轮上,圆周上都有一个指定点.首先,两个点都处于12点钟的位置,因此它们是重合的.随着旋转开始,它们将分开.您要绘制的是内轮上的点相对于外轮上的点的位置以及车轮所有旋转角度的位置.正确吗?

现在这里是一小段C ++代码,它们计算这些相对位置并将它们放置在数组中:
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;
}



毫无疑问,一小段代码本来可以做得更优雅,但是我希望它尽可能简单.现在有了两个数组,您可以在窗口中可视化它们,将它们打印在列表中或其他任何东西.那将是问题的第二部分.如果要试验这些曲线,建议您熟悉Python语言和Spider框架.他们很容易学习,并且在进行此类实验时非常有帮助.当然它们是免费的,您可以通过google或在
上轻松找到它们
http://code.google.com/p/pythonxy/

如果我仍然误解了该问题,请随时为您的原始问题添加更多详细信息.产生疑问的原因是上述代码会产生一个圆(例如,Stephan_Lang aready在他的评论中提到).彼此相加或相减(具有相同频率)的圆形函数将再次产生圆.但是也许您想从该模型开始,而不是从转速等开始工作.

我希望这个小代码段能在整个过程中对您有所帮助.



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

http://code.google.com/p/pythonxy/

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.


我真的很担心我的帮助不是很有用.我正在介绍一个基于.NET和C#的完整解决方案.问题太简单了:仅是两个旋转的组合.如果您不知道如何计算,恐怕仅使用代码也将是一个问题.无论如何,请尝试.

首先,定义要使用的浮点类型和仅带有矢量和的2D矢量:

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:

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



现在,定义旋转,并且仅围绕中心{0,0}.总和旋转时,无论如何我们都需要平移坐标系(使用上面定义的"+").



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.

public class Rotation { //around {0, 0}

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

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

    Real radius, angularVelocity, initialPhase;

    void Initialize(Real radius, Real angularVelocity, Real phase) {
        this.radius = radius;
        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:

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



基本上就是这样.您可以使用最终的GetPosition立即渲染图形,也可以通过GetTrajectory生成点数组.以后可以将此轨迹导入任何地方以制作图片.我建议忘记我们讨论过的所有插值,而仅以足够小的步长生成点以给出准确的图片.计算速度非常快,因此您几乎不需要等待就可以计算成千上万的点.

例如,让我们展示如何使用System.Graphics进行渲染,该渲染可以与System.Drawing.Forms或类似的东西一起使用.让我们根据此库中定义的点添加名称空间和计算轨迹的函数:



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:

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



同样,此渲染可立即用于在事件Paint的句柄中或在某些控件的覆盖方法OnPaint的句柄中在屏幕上显示渲染的图形.为简单起见,我将显示一些位图并将其保存到文件中:



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:

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



有关使用System.DrawingSystem.Windows.Forms进行渲染的更多详细信息,请参见我过去的回答:
Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [在mdi子表单之间画线 [在面板上捕获图形 [ http://msdn.microsoft.com/en-us/library/ms747393.aspx [ ^ ].

—SA



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[^].

For WPF rendering, please see:
http://msdn.microsoft.com/en-us/library/ms747393.aspx[^].

—SA


除了外圆转弯和声称两个圆都留在原处(这是不可能的)外,该站点可能会有所帮助:
http://mathworld.wolfram.com/Hypocycloid.html [
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[^]


这篇关于新颖的曲线生成项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆