0
저는 최근에 처리와 애니메이션에서 시작되었습니다. 그래서 매우 새로운 것입니다! 또한 ... 내 삼각 흡혈. 가공으로 빗변을 따라 타원을 애니메이션하기
float ballPosX = 10;
float ballPosY = 10;
float boxPosX = 400;
float boxPosY = 500;
void setup() {
size(800,600);
background(0);
}
void draw() {
fill(0, 20);
rect(0, 0, width, height);
fill(0, 240, 0);
rect(boxPosX, boxPosY, 50, 50);
fill(240, 0, 0);
smooth();
ellipse(ballPosX, ballPosY, 15, 15);
// stroke(0,0,240);
// line(ballPosX, ballPosY, boxPosX, boxPosY);
// line(ballPosX, ballPosY, 10, boxPosY);
// line(10, boxPosY, boxPosX, boxPosY);
noStroke();
//work out a2 + b2 = c2 - Pythagoras
float a = boxPosX - ballPosX;
float b = boxPosY - ballPosY;
float c = sqrt(sq(a) + sq(b));
println("a: " + a + " b: " + b + " c: " + c);
//now get the angles
float C = radians(90.0);
float B = asin(a/c);
float A = radians(180) - C - B;
println("A: " + degrees(A));
println("B: " + degrees(B));
println("C: " + degrees(C));
//lets say b is 10, work out a
//we have the angles...
b = 10;
float sinA = sin(A);
float sinB = sin(B);
a = sinA/(sinB/b);
fill(240, 0, 0);
smooth();
ellipse(b, a, 15, 15);
for(int i = 0; i < 160; i++) {
b += 5;
sinA = sin(A);
sinB = sin(B);
a = sinA/(sinB/b);
println("new a:" + a);
fill(240, 0, 0);
smooth();
ellipse(b, a, 15, 15);
}
}
는 기본적으로 나는 점 X1, Y1에서 타원 및 포인트 X2, Y2에서 사각형이 있습니다
나는이 코드를 가지고있다. 직각 삼각형을 사용하여 타원을 c 선을 따라 그립니다. 위의 코드는 다소 차이가 있습니다.
아이디어는 서로 x = 0에서 시작하는 많은 타원을 가지며 동일한 방법을 사용하여 모든 타원이 사각형에 수렴되도록하는 것입니다.
희망적이라고 생각하세요! 어떤 도움을 주셔서 감사합니다!