我有n
张卡。每张卡的宽度为a
个单位
许多流行的纸牌游戏都展示了一张卡片,并在#34;位置(见下图),我也想这样做。通过使用以下公式,我能够将卡片放在弧形中:
// NOTE: UE4 uses a left-handed, Z-up coordinate system.
// (+X = Forward, +Y = Right, and +Z = Up)
// NOTE: Card meshes have their pivot points in the center of the mesh
// (meshSize * 0.5f = local origin of mesh)
// n = Number of card meshes
// a = Width of each card mesh
const auto arcWidth = 0.8f;
const auto arcHeight = 0.15f;
const auto rotationAngle = 30.f;
const auto deltaAngle = 180.f;
const auto delta = FMath::DegreesToRadians(deltaAngle) / (float)(n);
const auto halfDelta = delta * 0.5f;
const auto halfMeshWidth = a * 0.5f;
const auto radius = halfMeshWidth + (rotationAngle / FMath::Tan(halfDelta));
for (unsigned y = 0; y < n; y++)
{
auto ArcX = (radius * arcWidth) * FMath::Cos(((float)y * delta) + halfDelta);
auto ArcY = (radius * arcHeight) * FMath::Sin(((float)y * delta) + halfDelta);
auto ArcVector = FVector(0.f, ArcX, ArcY);
// Draw a line from the world origin to the card origin
DrawDebugLine(GetWorld(), FVector::ZeroVector, ArcVector, FColor::Magenta, true, -1.f, 0, 2.5f);
}
无论我如何调整变量,最左边和最右边的牌都会被压在一起。我想这与圆的点如何分布有关,然后向下压扁(通过arcHeight
)形成一个椭圆?在任何情况下,您都可以看到结果远非相似,即使您仔细查看示例引用,也可以看到每个卡的中心存在一个弧(在这些卡在本地空间中旋转之前)。
我可以做些什么来实现更均匀间隔的弧?