|
发表于 2023-10-3 08:15:11
|
显示全部楼层
经实验将代码改为如下可行,求大佬们提供更好的写法(多处都要加 Assuming[{u > 0, v > 0}, xxx] 挺烦人的):
- ClearAll["Global`*"];b={0,0}; a={0,u}; d={v,0}; c={u+v, 0}; (* 令 AB=u, BD=v,则 BC=u+v *)(* E 在 AC 上且 DE=DC=u *)e = {x, y} /. Simplify@First@Assuming[{u > 0, v > 0}, Solve[{{x,y} \[Element] InfiniteLine[{a, c}] && EuclideanDistance[{x,y}, d] == u && 0 < x < v}, {x, y}]];Print["e = ", e]; (* 求直线{e, d} 和 直线{b, a} 的交点 *)f = {x, y} /. Simplify@First@Solve[Cross[#1 - {x, y}] . (#2 - {x, y}) == 0 & @@@ {{e, d}, {b, a}}, {x, y}];Print["f = ", f];lenAfAndFe = Assuming[{u > 0, v > 0}, FullSimplify[(EuclideanDistance[a, f] + EuclideanDistance[f, e])]];Print["AF+FE = ", lenAfAndFe, " , BD = v,两者当相等"]
复制代码 |
|