给定一些约束,对等腰三角形的两个剩余顶点进行采样

Sample two remaining vertices of isosceles triangle, given some constraints

三角函数问题:

我想找到一种方法,在给定一个初始坐标 C1 的情况下,随机采样等腰三角形的两个剩余顶点 C2C3 的坐标。我有一个顶点的坐标(C1),顶点与其余两个顶点之间的角度(我们称之为 theta),以及 C1 与其余两个顶点之间的距离 C2C3(我们称它为 R:我的意思是等腰三角形,R 描述了从 C1C2 以及从 C1C3)

如何随机选择两个满足theta度(相对于C1)且相同的有效点C2C3C1?

的距离 R

我知道与这里相关的关系是:

h = R * cos(0.5 * theta) # the length of the line between C1 and the 'base' of the triangle, i.e. the line between C2 and C3

x = R * sin(0.5 * theta) # half the length of the base, i.e. the line between C2 and C3

通过在 Ox 线和 (c1, c2) 线之间选择一个随机角度来做到这一点非常容易,我们称之为 alpha。

这是 Julia 代码

c1 = [0,0]
R = 5
theta = 0.3

function rotation_matrix(theta::Real)
    @. theta * [1 -1; 1 1] |> [cos sin; sin cos]
end

alpha = 2pi * rand(Float64)

c2 = R * rotation_matrix(alpha) * [1,0] + c1
c3 = R * rotation_matrix(alpha + theta) * [1,0] + c1