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))
    

      

  • 相关阅读:
    数据请求加密
    小程序获取用户的信息
    poi excel导出单元格写保护设置
    hadoop eclipse开发时报错
    RC4算法
    python的闭包
    Vulnerability of SSL to ChosenPlaintext Attack 读书报告
    SSL/TLS/WTLS
    python3程序开发指南——第1章 笔记
    centos6.4中文输入法
  • 原文地址:https://www.cnblogs.com/darkchii/p/12667848.html
Copyright © 2011-2022 走看看