zoukankan      html  css  js  c++  java
  • python

      未完成,有空再继续完善。。

      代码:

    import numpy as np
    
    
    def point_to_line_distance(a, b, c, x0, y0):
        return np.abs(a * x0 + b * y0 + c) / np.sqrt(a * a + b * b)
    
    
    def point_to_plane_distance(a, b, c, d, x0, y0, z0):
        return np.abs(a * x0 + b * y0 + c * z0 + d) / np.sqrt(a * a + b * b + c * c)
    
    
    def point_slope_to_intercept(x0, y0, slope):
        return y0 - (-1. / slope) * x0
    
    
    def parse_expression(exp: str = ''):
        return ''
    
    
    def point_is_in_area(x0, y0, trig_points):
        for x, y in trig_points:
            if x0 > x:
                pass
    
    
    def three_points_compute_area(points):
        point1 = points[0]
        point2 = points[1]
        point3 = points[2]
    
        vertor1 = point2 - point1
        vertor2 = point3 - point1
    
        normal_vector = np.cross(vertor1, vertor2)
    
        return 1. / 2. * np.sqrt(normal_vector.dot(normal_vector))
    
    
    def three_dimension_points_output_equation(points):
        point1 = points[0]
        point2 = points[1]
        point3 = points[2]
    
        vertor1 = point2 - point1
        vertor2 = point3 - point1
    
        normal_vector = np.cross(vertor1, vertor2)
    
        A = normal_vector[0]
        B = normal_vector[1]
        C = normal_vector[2]
        D = A * point1[0] + B * point1[1] + C * point1[2]
    
        return str(A) + 'x + ' + str(B) + 'y + ' + str(C) + 'z + ' + str(D) + ' = 0'
    
    
    if __name__ == '__main__':
        points = np.array(
            [
                [2, -1, 4],
                [-1, 3, -2],
                [0, 2, 3]
            ])
        print(three_points_compute_area(points))
    

      

  • 相关阅读:
    docker原理(转)
    HTTP代理(转)
    租房的注意事项
    聊聊常见的网络攻击
    我眼中的 Nginx(一):Nginx 和位运算
    5G网络与4G相比,有什么区别?
    当 “HTTP” 先生遇上“S”小姐
    虎牙直播张波:掘金Nginx日志
    又拍云张聪:OpenResty 动态流控的几种姿势
    一文读懂 HTTP/2 特性
  • 原文地址:https://www.cnblogs.com/darkchii/p/12667848.html
Copyright © 2011-2022 走看看