Python函数求等边三角形的一点

标签 python math geometry

我正在尝试编写一个函数 equiside(x, y): ,它需要两个形状为 (N,) 的 np.ndarrays ,其中 x 和 y 是自然的数字并返回点 z 形状为 (N,) 的 np.ndarray,使得 (x, y, z) 是等边三角形的顶点。

请推荐任何一个。

最佳答案

您可以使用以下程序来实现此目的。 您还可以将代码扩展为测试,如果点之间的距离相等。

    import numpy as np
    def equilateral(x, y):
                    
        v_x = (x[0]+y[0]+np.sqrt(3)*(x[1]-y[1]))/2 # This computes the `x coordinate` of the third vertex.
        v_y = (x[1]+y[1]+np.sqrt(3)*(x[0]-y[0]))/2 #This computes the 'y coordinate' of the third vertex. 
        z = np.array([v_x, v_y]) #This is point z, the third vertex. 
        return z

关于Python函数求等边三角形的一点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69671976/

相关文章:

python - 在 python 中设置监视器电源状态?

math - 除以零 : Infinite, NaN,还是零除法错误?

Java 3D - 边界球体

iphone - UIButton:需要一个圆形点击区域

javascript - 如何在 JupyterLab 中通过 JavaScript 评估文档上下文中的 Python 代码?

python - Pyinstaller 错误 - "setuptools distribution was not found"

python - 停止从串口读取字节(Python/RPi/UART)

python - 加速随机矩阵计算

ruby - 为什么在 Ruby 中是 Float::INFINITY == Float::INFINITY?

geometry - 弹开圆球