查看:MyTool.Static.TriangleSolutions解三角形
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MyTool.Dynamic
{
///
/// 全解三角形
///
public class CompleteTriangle
{
private float A_Angle = 0;//角
private float B_Angle = 0;
private float C_Angle = 0;
private float A_Edge = 0;//边
private float B_Edge = 0;
private float C_Edge = 0;
private float diameter;//外接圆半径
//=================================================
///
/// 返回三角形的角A [正数]
///
public float GetA_Angle { get { return A_Angle; } }
///
/// 返回三角形的角B [正数]
///
public float GetB_Angle { get { return B_Angle; } }
///
/// 返回三角形的角C [正数]
///
public float GetC_Angle { get { return C_Angle; } }
///
/// 返回三角形的角A对边
///
public float GetA_Edge { get { return A_Edge; } }
///
/// 返回三角形的角B对边
///
public float GetB_Edge { get { return B_Edge; } }
///
/// 返回三角形的角C对边
///
public float GetC_Edge { get { return C_Edge; } }
///
/// 返回三角形的外接圆半径
///
public float Get_diameter { get { return diameter; } }
//=[三角形全解]=================================================
///
/// 边边边 :
/// 提供 : 三角形的三个边 , 全解三角形
///
/// 角A的对边
/// 角B的对边
/// 角C的对边
///
public CompleteTriangle SolutionsTriangle_EEE(float A_Edge, float B_Edge, float C_Edge)
{//只有3边解三角,钝角锐角都可解
A_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_EEE(A_Edge, B_Edge, C_Edge);
B_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_EEE(B_Edge, A_Edge, C_Edge);
C_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_EEE(C_Edge, A_Edge, B_Edge);
return this;
}
///
/// 角边边 :
/// 提供 : 一个角和两个边 , 全解三角形
///
/// 角A
/// 角A的对边
/// 角B的对边
/// 角B优先解为钝角,一般为false
///
public CompleteTriangle SolutionsTriangle_AEE(float A_Angle, float A_Edge, float B_Edge, bool B_ObtuseAngle)
{//1角2边解三角,钝角锐角都可解,B_ObtuseAngle钝角优先解
diameter = MyTool.Static.TriangleSolutions.Getdiameter_Edge_Angle(A_Angle, A_Edge);
B_Angle = MyTool.Static.TriangleSolutions.GetAngle_Edge_diameter(B_Edge, diameter);//获得<=90的角
C_Angle = 90 - MyTool.Static.TriangleSolutions.Get_A_Angle_AAA(90 - A_Angle, B_Angle);//绕一圈获得c角
C_Edge = MyTool.Static.TriangleSolutions.GetEdge_Angle_diameter(C_Angle, diameter);//通过角获得边
if (A_Angle <= 90 && B_ObtuseAngle)
{//b为钝角优先解
B_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_AAA(A_Angle, C_Angle);//角b为钝角重计算
}
else
{
C_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_AAA(A_Angle, B_Angle);//c为钝角优先解
C_Edge = MyTool.Static.TriangleSolutions.GetEdge_Angle_diameter(C_Angle, diameter);//通过角获得边
}
return this;
}
///
/// 边角边 :
/// 提供 : 两个边和一个夹角 , 全解三角形
///
/// 角A的对边
/// 夹角B
/// 角C的对边
///
public CompleteTriangle SolutionsTriangle_EAE(float A_Edge, float B_Angle, float C_Edge)
{//两边夹一角解三角,钝角锐角都可解
B_Edge = MyTool.Static.TriangleSolutions.Get_A_Edge_EAE(B_Angle, A_Edge, C_Edge);
A_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_EEE(A_Edge, C_Edge, B_Edge);
C_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_EEE(C_Edge, A_Edge, B_Edge);
return this;
}
///
/// 角边角 :
/// 提供 : 两个角夹和一个边 , 全解三角形
///
/// 角A
/// 角B的对边
/// 角C
///
public CompleteTriangle SolutionsTriangle_AEA(float A_Angle, float B_Edge, float C_Angle)
{//两角夹一边解三角,钝角锐角都可解
B_Angle = MyTool.Static.TriangleSolutions.Get_A_Angle_AAA(A_Angle, C_Angle);//暂时求出不定角
diameter = MyTool.Static.TriangleSolutions.Getdiameter_Edge_Angle(B_Angle, B_Edge);//获取外接直径
A_Edge = MyTool.Static.TriangleSolutions.GetEdge_Angle_diameter(A_Angle, diameter);//通过角获得边
C_Edge = MyTool.Static.TriangleSolutions.GetEdge_Angle_diameter(C_Angle, diameter);//通过角获得边
return this;
}
}
}
查看:MyTool.Static.TriangleSolutions解三角形