搜索
bottom↓
回复: 60

平面几何计算系列原创代码开源

  [复制链接]

出10入23汤圆

发表于 2016-4-7 21:26:10 | 显示全部楼层 |阅读模式
    如题,本帖主要内容为一些计算代码的开源,有简单的也有复杂的,保证原创!原代码开源在本人的blog,附网址(花生壳搭的,不稳定):http://xxxzzc.imwork.net:25245/zzc/
    一楼占楼,陆续更新!

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》

出10入23汤圆

 楼主| 发表于 2016-4-7 21:26:47 | 显示全部楼层
几何计算——线段长度
  1. #include <stdio.h>
  2. #include <math.h>

  3. typedef struct tagPOINT
  4. {
  5.         double x;
  6.         double y;
  7. }POINT;

  8. typedef struct tagLINE
  9. {
  10.         POINT point_beg;
  11.         POINT point_end;
  12. }LINE;

  13. double GetLineLength(const LINE* line_demo)
  14. {
  15.         double dx, dy;
  16.         dx = line_demo->point_end.x - line_demo->point_beg.x;
  17.         dy = line_demo->point_end.y - line_demo->point_beg.y;
  18.         return sqrt(dx * dx + dy * dy);
  19. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:27:37 | 显示全部楼层
几何计算——点到线段的距离
  1. #include <stdio.h>
  2. #include <math.h>

  3. typedef struct tagPOINT
  4. {
  5.         double x;
  6.         double y;
  7. }POINT;

  8. typedef struct tagLINE
  9. {
  10.         POINT point_beg;
  11.         POINT point_end;
  12. }LINE;

  13. double GetLineLength(const LINE* line_demo)
  14. {
  15.         double dx, dy;
  16.         dx = line_demo->point_end.x - line_demo->point_beg.x;
  17.         dy = line_demo->point_end.y - line_demo->point_beg.y;
  18.         return sqrt(dx * dx + dy * dy);
  19. }

  20. double Distance_PointToLine(const POINT* point_demo, const LINE* line_demo)
  21. {
  22.         double line_length, cal_temp = 0.0f;
  23.         line_length = GetLineLength(line_demo);       
  24.         cal_temp += line_demo->point_beg.y * line_demo->point_end.x;
  25.         cal_temp -= line_demo->point_beg.x * line_demo->point_end.y;
  26.         cal_temp += line_demo->point_end.y * point_demo->x;
  27.         cal_temp -= line_demo->point_end.x * point_demo->y;
  28.         cal_temp += point_demo->y * line_demo->point_beg.x;
  29.         cal_temp -= point_demo->x * line_demo->point_beg.y;
  30.         return cal_temp / line_length;
  31. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:28:09 | 显示全部楼层
几何计算——三角形的重心
  1. #include <stdio.h>
  2. #include <math.h>

  3. typedef struct tagPOINT
  4. {
  5.         double x;
  6.         double y;
  7. }POINT;

  8. typedef struct tagTRI_ANGLE
  9. {
  10.         POINT point[3];
  11. }TRI_ANGLE;

  12. void GetTriangleBaryCenter(const const TRI_ANGLE* demo, POINT* barycenter)
  13. {
  14.         barycenter->x = (demo->point[0].x + demo->point[1].x + demo->point[2].x) / 3;
  15.         barycenter->y = (demo->point[0].y + demo->point[1].y + demo->point[2].y) / 3;
  16. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:28:39 | 显示全部楼层
几何计算——三角形的面积
  1. #include <stdio.h>
  2. #include <math.h>

  3. typedef struct tagPOINT
  4. {
  5.         double x;
  6.         double y;
  7. }POINT;

  8. typedef struct tagTRI_ANGLE
  9. {
  10.         POINT point[3];
  11. }TRI_ANGLE;

  12. double GetTriangleArea(const TRI_ANGLE* demo)
  13. {
  14.         double area = 0.0f;
  15.         area += demo->point[0].y * demo->point[1].x;
  16.         area -= demo->point[0].x * demo->point[1].y;
  17.         area += demo->point[1].y * demo->point[2].x;
  18.         area -= demo->point[1].x * demo->point[2].y;
  19.         area += demo->point[2].y * demo->point[0].x;
  20.         area -= demo->point[2].x * demo->point[0].y;
  21.         return area * 0.5;
  22. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:29:06 | 显示全部楼层
几何计算——两条直线的交点
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>

  4. typedef struct tagPOINT
  5. {
  6.         double x;
  7.         double y;
  8. }POINT;

  9. typedef struct tagLINE
  10. {
  11.         POINT point_beg;
  12.         POINT point_end;
  13. }LINE;

  14. int GetLineCross(const LINE* line0, const LINE* line1, POINT* point_cross)
  15. {
  16.         double x1_x2, x3_x4, y1_y2, y3_y4, xy12, xy34, gain_all;
  17.         x1_x2 = line0->point_beg.x - line0->point_end.x;
  18.         y1_y2 = line0->point_beg.y - line0->point_end.y;
  19.         x3_x4 = line1->point_beg.x - line1->point_end.x;
  20.         y3_y4 = line1->point_beg.y - line1->point_end.y;
  21.         gain_all = x1_x2 * y3_y4 - y1_y2 * x3_x4;
  22.         if (abs(gain_all) < DBL_EPSILON)
  23.         {
  24.                 return -1;
  25.         }
  26.         xy12 = line0->point_beg.x * line0->point_end.y - line0->point_end.x * line0->point_beg.y;
  27.         xy34 = line1->point_beg.x * line1->point_end.y - line1->point_end.x * line1->point_beg.y;
  28.         gain_all = 1.0 / gain_all;
  29.         point_cross->x = (xy12 * x3_x4 - xy34 * x1_x2) * gain_all;
  30.         point_cross->y = (xy12 * y3_y4 - xy34 * y1_y2) * gain_all;
  31.         return 0;
  32. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:29:36 | 显示全部楼层
几何计算——判断两线段是否相交
  1. #include <stdio.h>
  2. #include <math.h>

  3. typedef struct tagPOINT
  4. {
  5.         double x;
  6.         double y;
  7. }POINT;

  8. typedef struct tagLINE
  9. {
  10.         POINT point_beg;
  11.         POINT point_end;
  12. }LINE;

  13. int IsLineCross(const LINE* line0, const LINE* line1)
  14. {
  15.         double cal_temp0, cal_temp1;
  16.         cal_temp0 = 0.0f;
  17.         cal_temp0 += line0->point_beg.x * line0->point_end.y;
  18.         cal_temp0 -= line0->point_beg.y * line0->point_end.x;
  19.         cal_temp1 = cal_temp0;
  20.         cal_temp0 += line0->point_end.x * line1->point_beg.y;
  21.         cal_temp0 -= line0->point_end.y * line1->point_beg.x;
  22.         cal_temp1 += line0->point_end.x * line1->point_end.y;
  23.         cal_temp1 -= line0->point_end.y * line1->point_end.x;
  24.         cal_temp0 += line1->point_beg.x * line0->point_beg.y;
  25.         cal_temp0 -= line1->point_beg.y * line0->point_beg.x;
  26.         cal_temp1 += line1->point_end.x * line0->point_beg.y;
  27.         cal_temp1 -= line1->point_end.y * line0->point_beg.x;
  28.         if (cal_temp0 * cal_temp1 > 0.0f)
  29.         {
  30.                 return 0;
  31.         }
  32.         cal_temp0 = 0.0f;
  33.         cal_temp0 += line1->point_beg.x * line1->point_end.y;
  34.         cal_temp0 -= line1->point_beg.y * line1->point_end.x;
  35.         cal_temp1 = cal_temp0;
  36.         cal_temp0 += line1->point_end.x * line0->point_beg.y;
  37.         cal_temp0 -= line1->point_end.y * line0->point_beg.x;
  38.         cal_temp1 += line1->point_end.x * line0->point_end.y;
  39.         cal_temp1 -= line1->point_end.y * line0->point_end.x;
  40.         cal_temp0 += line0->point_beg.x * line1->point_beg.y;
  41.         cal_temp0 -= line0->point_beg.y * line1->point_beg.x;
  42.         cal_temp1 += line0->point_end.x * line1->point_beg.y;
  43.         cal_temp1 -= line0->point_end.y * line1->point_beg.x;
  44.         if (cal_temp0 * cal_temp1 > 0.0f)
  45.         {
  46.                 return 0;
  47.         }
  48.         return -1;
  49. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:30:06 | 显示全部楼层
几何计算——过某一点做某条直线的垂线(一)
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>

  4. typedef struct tagPOINT
  5. {
  6.         double x;
  7.         double y;
  8. }POINT;

  9. typedef struct tagLINE
  10. {
  11.         POINT point_beg;
  12.         POINT point_end;
  13. }LINE;

  14. int GetLineCross(const LINE* line0, const LINE* line1, POINT* point_cross)
  15. {
  16.         double x1_x2, x3_x4, y1_y2, y3_y4, xy12, xy34, gain_all;
  17.         x1_x2 = line0->point_beg.x - line0->point_end.x;
  18.         y1_y2 = line0->point_beg.y - line0->point_end.y;
  19.         x3_x4 = line1->point_beg.x - line1->point_end.x;
  20.         y3_y4 = line1->point_beg.y - line1->point_end.y;
  21.         gain_all = x1_x2 * y3_y4 - y1_y2 * x3_x4;
  22.         if (abs(gain_all) < DBL_EPSILON)
  23.         {
  24.                 return -1;
  25.         }
  26.         xy12 = line0->point_beg.x * line0->point_end.y - line0->point_end.x * line0->point_beg.y;
  27.         xy34 = line1->point_beg.x * line1->point_end.y - line1->point_end.x * line1->point_beg.y;
  28.         gain_all = 1.0 / gain_all;
  29.         point_cross->x = (xy12 * x3_x4 - xy34 * x1_x2) * gain_all;
  30.         point_cross->y = (xy12 * y3_y4 - xy34 * y1_y2) * gain_all;
  31.         return 0;
  32. }

  33. int GetVerticalPoint(const POINT* point_demo, const LINE* line_demo, POINT* dst)
  34. {
  35.         LINE line_temp;
  36.         line_temp.point_beg = *point_demo;
  37.         line_temp.point_end.x = point_demo->x + line_demo->point_end.x - line_demo->point_beg.x;
  38.         line_temp.point_end.y = point_demo->y + line_demo->point_beg.y - line_demo->point_end.y;
  39.         if (0 != GetLineCross((const LINE*)&line_temp, line_demo, dst))
  40.         {
  41.                 return -1;
  42.         }
  43.         return 0;
  44. }

  45. int GetVerticalLine(const POINT* point_demo, const LINE* line_demo, LINE* dst)
  46. {
  47.         dst->point_beg = *point_demo;
  48.         if (0 != GetVerticalPoint(point_demo, line_demo, &(dst->point_end)))
  49.         {
  50.                 return -1;
  51.         }
  52.         return 0;
  53. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:30:33 | 显示全部楼层
几何计算——过某一点做某条直线的垂线(二)
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>

  4. typedef struct tagPOINT
  5. {
  6.         double x;
  7.         double y;
  8. }POINT;

  9. typedef struct tagLINE
  10. {
  11.         POINT point_beg;
  12.         POINT point_end;
  13. }LINE;

  14. int GetVerticalPoint(const POINT* point_demo, const LINE* line_demo, POINT* dst)
  15. {
  16.         double line_demo_dx, line_demo_dy, cal_temp = 0.0f;
  17.         line_demo_dx = line_demo->point_end.x - line_demo->point_beg.x;
  18.         line_demo_dy = line_demo->point_end.y - line_demo->point_beg.y;
  19.         cal_temp += line_demo->point_beg.y * line_demo->point_end.x;
  20.         cal_temp -= line_demo->point_beg.x * line_demo->point_end.y;
  21.         cal_temp += line_demo->point_end.y * point_demo->x;
  22.         cal_temp -= line_demo->point_end.x * point_demo->y;
  23.         cal_temp += point_demo->y * line_demo->point_beg.x;
  24.         cal_temp -= point_demo->x * line_demo->point_beg.y;
  25.         cal_temp /= (line_demo_dx * line_demo_dx + line_demo_dy * line_demo_dy);
  26.         dst->x = point_demo->x - line_demo_dy * cal_temp;
  27.         dst->y = point_demo->y + line_demo_dx * cal_temp;
  28.         return 0;
  29. }

  30. int GetVerticalLine(const POINT* point_demo, const LINE* line_demo, LINE* dst)
  31. {
  32.         dst->point_beg = *point_demo;
  33.         if (0 != GetVerticalPoint(point_demo, line_demo, &(dst->point_end)))
  34.         {
  35.                 return -1;
  36.         }
  37.         return 0;
  38. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:30:59 | 显示全部楼层
几何计算——三角形的垂心(一)
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>

  4. typedef struct tagPOINT
  5. {
  6.         double x;
  7.         double y;
  8. }POINT;

  9. typedef struct tagLINE
  10. {
  11.         POINT point_beg;
  12.         POINT point_end;
  13. }LINE;

  14. typedef struct tagTRI_ANGLE
  15. {
  16.         POINT point[3];
  17. }TRI_ANGLE;

  18. int GetLineCross(const LINE* line0, const LINE* line1, POINT* point_cross)
  19. {
  20.         double x1_x2, x3_x4, y1_y2, y3_y4, xy12, xy34, gain_all;
  21.         x1_x2 = line0->point_beg.x - line0->point_end.x;
  22.         y1_y2 = line0->point_beg.y - line0->point_end.y;
  23.         x3_x4 = line1->point_beg.x - line1->point_end.x;
  24.         y3_y4 = line1->point_beg.y - line1->point_end.y;
  25.         gain_all = x1_x2 * y3_y4 - y1_y2 * x3_x4;
  26.         if (abs(gain_all) < DBL_EPSILON)
  27.         {
  28.                 return -1;
  29.         }
  30.         xy12 = line0->point_beg.x * line0->point_end.y - line0->point_end.x * line0->point_beg.y;
  31.         xy34 = line1->point_beg.x * line1->point_end.y - line1->point_end.x * line1->point_beg.y;
  32.         gain_all = 1.0 / gain_all;
  33.         point_cross->x = (xy12 * x3_x4 - xy34 * x1_x2) * gain_all;
  34.         point_cross->y = (xy12 * y3_y4 - xy34 * y1_y2) * gain_all;
  35.         return 0;
  36. }

  37. int GetVerticalPoint(const POINT* point_demo, const LINE* line_demo, POINT* dst)
  38. {
  39.         LINE line_temp;
  40.         line_temp.point_beg = *point_demo;
  41.         line_temp.point_end.x = point_demo->x + line_demo->point_end.x - line_demo->point_beg.x;
  42.         line_temp.point_end.y = point_demo->y + line_demo->point_beg.y - line_demo->point_end.y;
  43.         if (0 != GetLineCross((const LINE*)&line_temp, line_demo, dst))
  44.         {
  45.                 return -1;
  46.         }
  47.         return 0;
  48. }

  49. int GetVerticalLine(const POINT* point_demo, const LINE* line_demo, LINE* dst)
  50. {
  51.         dst->point_beg = *point_demo;
  52.         if (0 != GetVerticalPoint(point_demo, line_demo, &(dst->point_end)))
  53.         {
  54.                 return -1;
  55.         }
  56.         return 0;
  57. }

  58. int GetTri_angleVertical(const TRI_ANGLE* tri_angle_demo, POINT* point_demo)
  59. {
  60.         LINE line_temp0, line_temp1;
  61.         LINE line_vertical0, line_vertical1;
  62.         line_temp0.point_beg = tri_angle_demo->point[1];
  63.         line_temp0.point_end = tri_angle_demo->point[2];
  64.         if (0 != GetVerticalLine((const POINT*)(tri_angle_demo->point), (const LINE*)&line_temp0, &line_vertical0))
  65.         {
  66.                 return -1;
  67.         }
  68.         line_temp0.point_beg = tri_angle_demo->point[2];
  69.         line_temp0.point_end = tri_angle_demo->point[0];
  70.         if (0 != GetVerticalLine((const POINT*)(tri_angle_demo->point) + 1, (const LINE*)&line_temp1, &line_vertical1))
  71.         {
  72.                 return -1;
  73.         }
  74.         if (0 != GetLineCross((const LINE*)&line_vertical0, (const LINE*)&line_vertical1, point_demo))
  75.         {
  76.                 return -1;
  77.         }
  78.         return 0;
  79. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:31:29 | 显示全部楼层
几何计算——三角形的垂心(二)
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>

  4. typedef struct tagPOINT
  5. {
  6.         double x;
  7.         double y;
  8. }POINT;

  9. typedef struct tagLINE
  10. {
  11.         POINT point_beg;
  12.         POINT point_end;
  13. }LINE;

  14. typedef struct tagTRI_ANGLE
  15. {
  16.         POINT point[3];
  17. }TRI_ANGLE;

  18. int GetVerticalPoint(const POINT* point_demo, const LINE* line_demo, POINT* dst)
  19. {
  20.         double line_demo_dx, line_demo_dy, cal_temp = 0.0f;
  21.         line_demo_dx = line_demo->point_end.x - line_demo->point_beg.x;
  22.         line_demo_dy = line_demo->point_end.y - line_demo->point_beg.y;
  23.         cal_temp += line_demo->point_beg.y * line_demo->point_end.x;
  24.         cal_temp -= line_demo->point_beg.x * line_demo->point_end.y;
  25.         cal_temp += line_demo->point_end.y * point_demo->x;
  26.         cal_temp -= line_demo->point_end.x * point_demo->y;
  27.         cal_temp += point_demo->y * line_demo->point_beg.x;
  28.         cal_temp -= point_demo->x * line_demo->point_beg.y;
  29.         cal_temp /= (line_demo_dx * line_demo_dx + line_demo_dy * line_demo_dy);
  30.         dst->x = point_demo->x - line_demo_dy * cal_temp;
  31.         dst->y = point_demo->y + line_demo_dx * cal_temp;
  32.         return 0;
  33. }

  34. int GetVerticalLine(const POINT* point_demo, const LINE* line_demo, LINE* dst)
  35. {
  36.         dst->point_beg = *point_demo;
  37.         if (0 != GetVerticalPoint(point_demo, line_demo, &(dst->point_end)))
  38.         {
  39.                 return -1;
  40.         }
  41.         return 0;
  42. }

  43. int GetLineCross(const LINE* line0, const LINE* line1, POINT* point_cross)
  44. {
  45.         double x1_x2, x3_x4, y1_y2, y3_y4, xy12, xy34, gain_all;
  46.         x1_x2 = line0->point_beg.x - line0->point_end.x;
  47.         y1_y2 = line0->point_beg.y - line0->point_end.y;
  48.         x3_x4 = line1->point_beg.x - line1->point_end.x;
  49.         y3_y4 = line1->point_beg.y - line1->point_end.y;
  50.         gain_all = x1_x2 * y3_y4 - y1_y2 * x3_x4;
  51.         if (abs(gain_all) < DBL_EPSILON)
  52.         {
  53.                 return -1;
  54.         }
  55.         xy12 = line0->point_beg.x * line0->point_end.y - line0->point_end.x * line0->point_beg.y;
  56.         xy34 = line1->point_beg.x * line1->point_end.y - line1->point_end.x * line1->point_beg.y;
  57.         gain_all = 1.0 / gain_all;
  58.         point_cross->x = (xy12 * x3_x4 - xy34 * x1_x2) * gain_all;
  59.         point_cross->y = (xy12 * y3_y4 - xy34 * y1_y2) * gain_all;
  60.         return 0;
  61. }

  62. int GetTri_angleVertical(const TRI_ANGLE* tri_angle_demo, POINT* point_demo)
  63. {
  64.         LINE line_temp0, line_temp1;
  65.         LINE line_vertical0, line_vertical1;
  66.         line_temp0.point_beg = tri_angle_demo->point[1];
  67.         line_temp0.point_end = tri_angle_demo->point[2];
  68.         if (0 != GetVerticalLine((const POINT*)(tri_angle_demo->point), (const LINE*)&line_temp0, &line_vertical0))
  69.         {
  70.                 return -1;
  71.         }
  72.         line_temp0.point_beg = tri_angle_demo->point[2];
  73.         line_temp0.point_end = tri_angle_demo->point[0];
  74.         if (0 != GetVerticalLine((const POINT*)(tri_angle_demo->point) + 1, (const LINE*)&line_temp1, &line_vertical1))
  75.         {
  76.                 return -1;
  77.         }
  78.         if (0 != GetLineCross((const LINE*)&line_vertical0, (const LINE*)&line_vertical1, point_demo))
  79.         {
  80.                 return -1;
  81.         }
  82.         return 0;
  83. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:32:01 | 显示全部楼层
几何计算——三角形的内心(角平分线的交点)
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <float.h>

  4. typedef struct tagPOINT
  5. {
  6.         double x;
  7.         double y;
  8. }POINT;

  9. typedef struct tagLINE
  10. {
  11.         POINT point_beg;
  12.         POINT point_end;
  13. }LINE;

  14. typedef struct tagTRI_ANGLE
  15. {
  16.         POINT point[3];
  17. }TRI_ANGLE;

  18. double GetLineLength(const LINE* line_demo)
  19. {
  20.         double dx, dy;
  21.         dx = line_demo->point_end.x - line_demo->point_beg.x;
  22.         dy = line_demo->point_end.y - line_demo->point_beg.y;
  23.         return sqrt(dx * dx + dy * dy);
  24. }

  25. double GetTriangleArea(const TRI_ANGLE* demo)
  26. {
  27.         double area = 0.0f;
  28.         area += demo->point[0].y * demo->point[1].x;
  29.         area -= demo->point[0].x * demo->point[1].y;
  30.         area += demo->point[1].y * demo->point[2].x;
  31.         area -= demo->point[1].x * demo->point[2].y;
  32.         area += demo->point[2].y * demo->point[0].x;
  33.         area -= demo->point[2].x * demo->point[0].y;
  34.         return area * 0.5;
  35. }
  36. int GetLineCross(const LINE* line0, const LINE* line1, POINT* point_cross)
  37. {
  38.         double x1_x2, x3_x4, y1_y2, y3_y4, xy12, xy34, gain_all;
  39.         x1_x2 = line0->point_beg.x - line0->point_end.x;
  40.         y1_y2 = line0->point_beg.y - line0->point_end.y;
  41.         x3_x4 = line1->point_beg.x - line1->point_end.x;
  42.         y3_y4 = line1->point_beg.y - line1->point_end.y;
  43.         gain_all = x1_x2 * y3_y4 - y1_y2 * x3_x4;
  44.         if (abs(gain_all) < DBL_EPSILON)
  45.         {
  46.                 return -1;
  47.         }
  48.         xy12 = line0->point_beg.x * line0->point_end.y - line0->point_end.x * line0->point_beg.y;
  49.         xy34 = line1->point_beg.x * line1->point_end.y - line1->point_end.x * line1->point_beg.y;
  50.         gain_all = 1.0 / gain_all;
  51.         point_cross->x = (xy12 * x3_x4 - xy34 * x1_x2) * gain_all;
  52.         point_cross->y = (xy12 * y3_y4 - xy34 * y1_y2) * gain_all;
  53.         return 0;
  54. }

  55. int GetTriangleInnerCenter(const TRI_ANGLE* triangle_demo, POINT* point_demo)
  56. {
  57.         double len01, len12, len20, s, r, dx0, dy0, dx1, dy1;
  58.         LINE temp_line01, temp_line12, temp_line20;
  59.         temp_line01.point_beg = triangle_demo->point[0];
  60.         temp_line01.point_end = triangle_demo->point[1];
  61.         temp_line12.point_beg = triangle_demo->point[1];
  62.         temp_line12.point_end = triangle_demo->point[2];
  63.         temp_line20.point_beg = triangle_demo->point[2];
  64.         temp_line20.point_end = triangle_demo->point[0];
  65.         len01 = GetLineLength((const LINE*)&temp_line01);
  66.         len12 = GetLineLength((const LINE*)&temp_line12);
  67.         len20 = GetLineLength((const LINE*)&temp_line20);
  68.         s = GetTriangleArea(triangle_demo);
  69.         r = s * 2 / (len01 + len12 + len20);
  70.         dx0 = (temp_line12.point_end.y - temp_line12.point_beg.y) * r / len12;
  71.         dy0 = (temp_line12.point_beg.x - temp_line12.point_end.x) * r / len12;
  72.         temp_line12.point_beg.x += dx0;
  73.         temp_line12.point_beg.x += dy0;
  74.         dx1 = (temp_line20.point_end.y - temp_line20.point_beg.y) * r / len20;
  75.         dy1 = (temp_line20.point_beg.x - temp_line20.point_end.x) * r / len20;
  76.         temp_line20.point_beg.x += dx1;
  77.         temp_line20.point_beg.x += dy1;
  78.         return GetLineCross((const LINE*)&temp_line12, (const LINE*)&temp_line20, point_demo);
  79. }
复制代码

出10入23汤圆

 楼主| 发表于 2016-4-7 21:33:16 | 显示全部楼层
今天代码暂时更新完毕,等装上matlab之后再上测试代码和测试图!
后续还有一部分算法代码更新!

出0入0汤圆

发表于 2016-4-7 21:37:39 | 显示全部楼层
非常好,谢谢

出10入23汤圆

 楼主| 发表于 2016-4-7 21:38:38 | 显示全部楼层

谢谢帮顶!

出0入0汤圆

发表于 2016-4-7 22:44:17 | 显示全部楼层
非常好,谢谢!敬礼!

出10入23汤圆

 楼主| 发表于 2016-4-7 23:26:07 来自手机 | 显示全部楼层
tarchen 发表于 2016-4-7 22:44
非常好,谢谢!敬礼!

谢谢关注

出0入0汤圆

发表于 2016-4-8 07:25:38 来自手机 | 显示全部楼层
谢谢楼主,已收藏

出0入0汤圆

发表于 2016-4-8 07:40:37 | 显示全部楼层
基础代码很重要,

出0入0汤圆

发表于 2016-4-8 08:22:17 来自手机 | 显示全部楼层
感谢楼主的基础代码

出0入22汤圆

发表于 2016-4-8 08:34:57 | 显示全部楼层
顶,数学不好的人表示看不懂

出0入0汤圆

发表于 2016-4-8 08:52:04 | 显示全部楼层
楼主能打个包么?这样或许更好

出10入23汤圆

 楼主| 发表于 2016-4-8 09:02:35 来自手机 | 显示全部楼层
chliken 发表于 2016-4-8 08:52
楼主能打个包么?这样或许更好

自己打吧,我自己也没有打包存档

出0入0汤圆

发表于 2016-4-8 09:07:58 | 显示全部楼层
谢谢楼主分享,先收藏了。

出0入0汤圆

发表于 2016-4-8 09:16:25 | 显示全部楼层
感谢开源,以后用的到

出0入0汤圆

发表于 2016-4-8 09:53:47 | 显示全部楼层
帮顶了  服务器是建在自己电脑?

出10入23汤圆

 楼主| 发表于 2016-4-8 09:56:34 来自手机 | 显示全部楼层
huangqi412 发表于 2016-4-8 09:53
帮顶了  服务器是建在自己电脑?

嗯,买了一个低功耗迷你主机

出0入0汤圆

发表于 2016-4-8 10:00:30 | 显示全部楼层
这个要支持,顺道大概说一下自己建的服务器

出0入0汤圆

发表于 2016-4-8 10:01:48 | 显示全部楼层
zouzhichao 发表于 2016-4-8 09:56
嗯,买了一个低功耗迷你主机

   端口号不是80   果断是家里搭。

出10入23汤圆

 楼主| 发表于 2016-4-8 10:05:20 来自手机 | 显示全部楼层
pazulin 发表于 2016-4-8 10:00
这个要支持,顺道大概说一下自己建的服务器

Appserv + 花生壳 + emblog模板

出10入23汤圆

 楼主| 发表于 2016-4-8 10:06:36 来自手机 | 显示全部楼层
huangqi412 发表于 2016-4-8 10:01
端口号不是80   果断是家里搭。

我也想用80端口啊,没辙

出0入0汤圆

发表于 2016-4-8 11:07:02 | 显示全部楼层
代码很规整,赏心悦目

出10入23汤圆

 楼主| 发表于 2016-4-8 11:21:07 来自手机 | 显示全部楼层
arm7tdmi 发表于 2016-4-8 11:07
代码很规整,赏心悦目

谢谢夸奖

出0入0汤圆

发表于 2016-4-8 12:20:00 | 显示全部楼层
帮顶。。。

出0入0汤圆

发表于 2016-4-9 06:22:08 来自手机 | 显示全部楼层
怎么对若干条首尾相接线段进行排序?直线圆弧如何旋转?求教。

出0入0汤圆

发表于 2016-4-9 06:50:08 | 显示全部楼层
不错的东东,谢谢分享

出10入23汤圆

 楼主| 发表于 2016-4-9 07:37:36 来自手机 | 显示全部楼层
hmd420304805 发表于 2016-4-9 06:22
怎么对若干条首尾相接线段进行排序?直线圆弧如何旋转?求教。

很快会更新,你说的这两个恰好都有写

出0入12汤圆

发表于 2016-4-9 07:37:59 来自手机 | 显示全部楼层
支持原创,感谢楼主

出0入0汤圆

发表于 2016-4-9 10:23:07 | 显示全部楼层
基础工作很重要,受教了。

出0入0汤圆

发表于 2016-4-9 10:27:56 | 显示全部楼层
顶一个,谢谢分享

出0入0汤圆

发表于 2016-4-9 10:37:34 来自手机 | 显示全部楼层
多谢楼主分享,很实用的工具软件

出0入4汤圆

发表于 2016-4-9 11:17:45 | 显示全部楼层
看了下,排版非常好,学习

出0入0汤圆

发表于 2016-4-9 13:34:00 | 显示全部楼层
感谢楼主,很有用

出0入0汤圆

发表于 2016-4-9 17:24:06 | 显示全部楼层
本帖最后由 hmd420304805 于 2016-4-9 17:25 编辑

我也把自己的递归排序放上来,抛砖引玉

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2016-4-13 17:38:27 | 显示全部楼层
平面几何计算 mark

出0入0汤圆

发表于 2016-4-13 17:42:47 | 显示全部楼层
非常好,不错!!!

出0入0汤圆

发表于 2016-4-13 17:46:56 来自手机 | 显示全部楼层
这个要顶,非常感谢

出0入0汤圆

发表于 2016-4-24 09:57:23 | 显示全部楼层

感谢楼主的基础代码

出0入4汤圆

发表于 2016-4-24 12:04:45 | 显示全部楼层
平面几何计算系列原创代码, 赞!
最好说说应用在哪

出10入23汤圆

 楼主| 发表于 2016-4-24 12:19:20 | 显示全部楼层
sunliezhi 发表于 2016-4-24 12:04
平面几何计算系列原创代码, 赞!
最好说说应用在哪

测绘,gui等

出0入0汤圆

发表于 2016-4-24 12:35:41 来自手机 | 显示全部楼层
楼主大大的好人啊

出0入0汤圆

发表于 2016-5-16 15:55:23 | 显示全部楼层
谢谢楼主的分享

出0入0汤圆

发表于 2016-5-16 16:16:01 | 显示全部楼层
技术活儿,该赏

出0入0汤圆

发表于 2016-5-16 16:27:42 | 显示全部楼层
谢谢楼主分享

出0入0汤圆

发表于 2016-5-16 17:36:33 | 显示全部楼层
不错,感谢楼主!

出0入0汤圆

发表于 2016-5-16 17:53:25 | 显示全部楼层
期待楼主继续更新

出0入0汤圆

发表于 2016-5-16 18:44:59 | 显示全部楼层
不错,mark!

出0入0汤圆

发表于 2016-5-16 19:13:23 来自手机 | 显示全部楼层
很好,谢谢楼主。

出20入62汤圆

发表于 2016-5-16 19:24:39 | 显示全部楼层
谢谢楼主分享,持续关注~~~平面几何计算

出0入0汤圆

发表于 2016-5-16 20:22:25 | 显示全部楼层
赞一下楼主!期待继续更新

出0入4汤圆

发表于 2016-5-16 22:59:04 来自手机 | 显示全部楼层
非常不错,保存下
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 16:39

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表