103 lines
2.9 KiB
C++
103 lines
2.9 KiB
C++
// #include "GeomOperation.h"
|
|
|
|
// double GeomOperation::GetDistance(std::shared_ptr<IModel> m1, std::shared_ptr<IModel> m2)
|
|
// {
|
|
// double d = -1;
|
|
// if (std::dynamic_pointer_cast<Point3D>(m1) != nullptr && std::dynamic_pointer_cast<Point3D>(m2) != nullptr)
|
|
// {
|
|
// std::shared_ptr<Point3D> p1 = std::static_pointer_cast<Point3D>(m1);
|
|
// std::shared_ptr<Point3D> p2 = std::static_pointer_cast<Point3D>(m2);
|
|
// d = std::sqrt(std::pow(p1->X - p2->X, 2) + std::pow(p1->Y - p2->Y, 2) + std::pow(p1->Z - p2->Z, 2));
|
|
// }
|
|
// else if (std::dynamic_pointer_cast<ScNode>(m1) != nullptr && std::dynamic_pointer_cast<ScNode>(m2) != nullptr)
|
|
// {
|
|
// std::shared_ptr<ScNode> p1 = std::static_pointer_cast<ScNode>(m1);
|
|
// std::shared_ptr<ScNode> p2 = std::static_pointer_cast<ScNode>(m2);
|
|
// d = std::sqrt(std::pow(p1->Y - p2->Y, 2) + std::pow(p1->Z - p2->Z, 2));
|
|
// }
|
|
// return d;
|
|
// }
|
|
|
|
// double GeomOperation::GetCircleRadius(double B, double f)
|
|
// {
|
|
// // double t = (Math.Abs(B) < Math.Abs(f)) ? B : f;
|
|
// // double d = (Math.Pow(B, 2) + Math.Pow(f, 2)) / (2 * Math.Abs(t));
|
|
// // return d;
|
|
|
|
// B = std::abs(B);
|
|
// f = std::abs(f);
|
|
// return (std::pow(B / 2, 2) + std::pow(f, 2)) / (2 * f);
|
|
// }
|
|
|
|
// double GeomOperation::GetCircleH(double R, double w, double f)
|
|
// {
|
|
// R = std::abs(R);
|
|
// double h = R - std::sqrt(R * R - w * w);
|
|
// return Math::Sign(f) * h;
|
|
// }
|
|
|
|
// double GeomOperation::GetCircleAngle(double R, double w, double h)
|
|
// {
|
|
// /*
|
|
// double a = 0;
|
|
// double t1; double t2;
|
|
// if (Math.Abs(w) > Math.Abs(h)) { t1 = Math.Abs(w); t2 = Math.Abs(h); }
|
|
// else
|
|
// {
|
|
// t1 = Math.Abs(h); t2 = Math.Abs(w);
|
|
// }
|
|
// // a = Math.Atan((2 * height * width) / (Math.Pow(width, 2) - Math.Pow(height, 2)));
|
|
// a = Math.Atan(t1 / (R-t2));
|
|
|
|
// a = a * 180 / Math.PI;
|
|
|
|
// return a;
|
|
// */
|
|
|
|
// R = std::abs(R);
|
|
// w = std::abs(w);
|
|
// h = std::abs(h);
|
|
// double a = std::atan(w / (R - h));
|
|
// a = a * 180 / PI;
|
|
|
|
// return a;
|
|
// }
|
|
|
|
// std::vector<double> GeomOperation::GetParabolaABC(double x1, double y1, double x2, double y2, double x3, double y3)
|
|
// {
|
|
// std::vector<double> abc(3);
|
|
|
|
// abc[0] = ((y1 - y2) / (x1 - x2) - (y1 - y3) / (x1 - x3)) / (x2 - x3);
|
|
// abc[1] = ((y1 - y2) - (x1 * x1 - x2 * x2) * abc[0]) / (x1 - x2);
|
|
// abc[2] = y1 - abc[0] * x1 * x1 - abc[1] * x1;
|
|
|
|
// // 抛物线顶点
|
|
// // double[] vt = new double[2];
|
|
// // vt[0] = -1 * abc[1] / (2 * abc[0]);
|
|
// // vt[1] = (4 * abc[0] * abc[2] - abc[1] * abc[1]) / (4 * abc[0]);
|
|
|
|
// return abc;
|
|
// }
|
|
|
|
// std::vector<double> GeomOperation::GetParabolaABC(double B, double f)
|
|
// {
|
|
// std::vector<double> abc(3);
|
|
|
|
// abc[0] = -4 * f / (B * B);
|
|
// abc[1] = 0;
|
|
// abc[2] = f;
|
|
|
|
// return abc;
|
|
// }
|
|
|
|
// double GeomOperation::GetParabolaH(double B, double f, double w)
|
|
// {
|
|
// std::vector<double> abc(3);
|
|
|
|
// abc[0] = -4 * f / (B * B);
|
|
// abc[1] = 0;
|
|
// abc[2] = f;
|
|
|
|
// return f - (abc[0] * w * w + abc[1] * w + abc[2]);
|
|
// }
|