두 번째 그룹의 입자가 각속도를 설정하여 입자가 그룹 중심에서 회전 할 수 있습니다.각속도를 2d 입자 그룹으로 설정
나는이 방법을 사용하여 그룹의 각속도를 얻었고 실제로 각도 그룹 속도를 설정하는 논리를 뒤집어 봤습니다.
제 생각에는 그룹 질량, 그룹 중심 및 그룹 선형 속도를 같은 방식으로 얻음으로써 대부분의 논리를 그대로 둡니다. 그러나 대부분의 시행 착오가 예상 결과에 미치지 못하는 것 같습니다.
이 논리 반전에서 각속도를 설정하는 방법에 대해 알고 있다면, 내가하는 말을 듣고 싶습니다.
getParticleGroupAngularVelocity()
{
particleCount = 30;
particleMass = 1.5;
particleGroupMass = 0;
particleGroupInertia = 0;
particleGroupAngularVelocity = 0;
particleGroupCenter = vector(0, 0);
particleGroupLinearVelocity = vector(0, 0);
for (i = 0; i < particleCount; i++)
{
particleGroupMass += particleMass;
particleGroupCenter += particleMass * particles[i].position;
particleGroupLinearVelocity += particleMass * particles[i].velocity;
}
if (particleGroupMass > 0)
{
particleGroupCenter *= 1/particleGroupMass;
particleGroupLinearVelocity *= 1/particleGroupMass;
}
for (i = 0; i < particleCount; i++)
{
pos = particles[i].position - particleGroupCenter;
vel = particles[i].velocity - particleGroupLinearVelocity;
particleGroupInertia += particleMass * (pos.x * pos.x + pos.y * pos.y);
particleGroupAngularVelocity += particleMass * (pos.x * vel.y - pos.y * vel.x);
}
if (particleGroupInertia > 0)
{
particleGroupAngularVelocity *= 1/particleGroupInertia;
}
return particleGroupAngularVelocity;
}
당신은 입자 그룹을 가지고 있으며 그룹에게 원하는 "그룹 각속도"를주기 위해 일부 또는 모든 입자의 속도를 변경하고자합니다 ""그룹 선형 속도 "를 동일하게 유지하면서이 코드와 동일한 의미로 느슨하게 용어를 사용합니다. 맞습니까? 다른 조건이 있습니까? 나는 * 할 수있는 많은 방법이 있기 때문에 물어 본다. – Beta
그룹의 선 속도를 유지하면서 모든 입자의 속도를 변경할 수 있기를 원합니다. 따라서 입자 그룹이 x 축 및/또는 y 축에서 일정한 속도로 움직이는 경우 다른 그룹의 움직임에 영향을주지 않고 입자 그룹을 중심에서 회전시킬 수 있기를 바랍니다. – Claudia
다른 조건은 다른 조건을 생각할 수 없습니다. 하지만 그 주제에 대한 통찰력이 부족할 수도 있습니다. – Claudia