12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- //
- // Academic License - for use in teaching, academic research, and meeting
- // course requirements at degree granting institutions only. Not for
- // government, commercial, or other organizational use.
- // File: distcal.cpp
- //
- // MATLAB Coder version : 5.3
- // C/C++ source code generated on : 27-Mar-2023 15:34:32
- //
- // Include Files
- #include "fun10_distcal.h"
- #include "rt_nonfinite.h"
- #include <cmath>
- // Function Definitions
- //
- // DISTCAL 计算距离
- // 此处显示详细说明
- //
- // Arguments : const double PlatA_data[]
- // const int PlatA_size[2]
- // const double PlatB_data[]
- // const int PlatB_size[2]
- // Return Type : double
- //
- double b_distcal(const double PlatA_data[], const int PlatA_size[2],
- const double PlatB_data[], const int PlatB_size[2])
- {
- double dist;
- dist = 0.0;
- if (PlatA_size[1] == PlatB_size[1]) {
- if (PlatA_size[1] == 2) {
- double a;
- double b_a;
- a = PlatA_data[0] - PlatB_data[0];
- b_a = PlatA_data[1] - PlatB_data[1];
- dist = std::sqrt(a * a + b_a * b_a);
- } else if (PlatA_size[1] == 3) {
- double a;
- double b_a;
- a = PlatA_data[0] - PlatB_data[0];
- b_a = PlatA_data[1] - PlatB_data[1];
- dist = std::sqrt(a * a + b_a * b_a);
- }
- } else {
- dist = -1.0;
- }
- return dist;
- }
- //
- // DISTCAL 计算距离
- // 此处显示详细说明
- //
- // Arguments : const double PlatA_data[]
- // const int PlatA_size[2]
- // const double PlatB_data[]
- // const int PlatB_size[2]
- // Return Type : double
- //
- double distcal(const double PlatA_data[], const int PlatA_size[2],
- const double PlatB_data[], const int PlatB_size[2])
- {
- double dist;
- dist = 0.0;
- if (PlatA_size[1] == PlatB_size[1]) {
- if (PlatA_size[1] == 2) {
- double a;
- double b_a;
- a = PlatA_data[0] - PlatB_data[0];
- b_a = PlatA_data[1] - PlatB_data[1];
- dist = std::sqrt(a * a + b_a * b_a);
- } else if (PlatA_size[1] == 3) {
- double a;
- double b_a;
- a = PlatA_data[0] - PlatB_data[0];
- b_a = PlatA_data[1] - PlatB_data[1];
- dist = std::sqrt(a * a + b_a * b_a);
- }
- } else {
- dist = -1.0;
- }
- return dist;
- }
- //
- // File trailer for distcal.cpp
- //
- // [EOF]
- //
|