【问题标题】:I need help creating a hypotrochoid in Processing我需要帮助在处理中创建下摆线
【发布时间】:2022-01-13 00:39:15
【问题描述】:

我需要帮助创建下摆线。从三个值(内半径、外半径和距离)开始,我需要通过计算一系列点、从点到点、到点等绘制直线来绘制形状。

我开始了一点,但我现在完全迷失了,不知道自己在做什么。任何事情都会有所帮助,谢谢。

下摆线:https://en.wikipedia.org/wiki/Hypotrochoid

float xpos,ypos,r,d,R,t,a,b;
int centerX,centerY,center;

void setup() {
 size(600,600);
 centerX = width/2;
 centerY = height/2;
 ellipse(300, 300, 300, 300);
 t = 25;
 a = 10;
 b = 5;

}

void draw(){
xpos=(a-b)*cos(t)+h*cos(((a-b)/b)*t);
ypos=(a-b)*sin(t)+h*sin(((a-b)/b)*t);
}

【问题讨论】:

    标签: java processing


    【解决方案1】:

    计算ypos时,你的公式有问题:

    ypos=(a-b)*sin(t)+h*sin(((a-b)/b)*t);

    ypos=(a-b)*sin(t) - h*sin(((a-b)/b)*t);
    

    计算角度t 作为frameCount 的函数并在每个坐标处绘制point

    int centerX, centerY;
    float a, b, h;
    
    void setup() {
       size(600,600);
       centerX = width/2;
       centerY = height/2;
       a = 100;
       b = 60;
       h = 100;
    }
    
    void draw(){  
        float t = frameCount * TWO_PI / 360;
        float x = (a-b)*cos(t) + h*cos((a-b)/b*t) + centerX;
        float y = (a-b)*sin(t) - h*sin((a-b)/b*t) + centerY;
        point(x, y);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      • 2012-10-16
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多