• <i id='dXq8W'><tr id='dXq8W'><dt id='dXq8W'><q id='dXq8W'><span id='dXq8W'><b id='dXq8W'><form id='dXq8W'><ins id='dXq8W'></ins><ul id='dXq8W'></ul><sub id='dXq8W'></sub></form><legend id='dXq8W'></legend><bdo id='dXq8W'><pre id='dXq8W'><center id='dXq8W'></center></pre></bdo></b><th id='dXq8W'></th></span></q></dt></tr></i><div id='dXq8W'><tfoot id='dXq8W'></tfoot><dl id='dXq8W'><fieldset id='dXq8W'></fieldset></dl></div>
    <legend id='dXq8W'><style id='dXq8W'><dir id='dXq8W'><q id='dXq8W'></q></dir></style></legend>
    • <bdo id='dXq8W'></bdo><ul id='dXq8W'></ul>

    <small id='dXq8W'></small><noframes id='dXq8W'>

    <tfoot id='dXq8W'></tfoot>

        沿 A-B 线计算距 A 给定距离的点

        时间:2023-07-25

        <small id='yirCU'></small><noframes id='yirCU'>

        <legend id='yirCU'><style id='yirCU'><dir id='yirCU'><q id='yirCU'></q></dir></style></legend>
          <bdo id='yirCU'></bdo><ul id='yirCU'></ul>
        • <tfoot id='yirCU'></tfoot>

                  <tbody id='yirCU'></tbody>
                1. <i id='yirCU'><tr id='yirCU'><dt id='yirCU'><q id='yirCU'><span id='yirCU'><b id='yirCU'><form id='yirCU'><ins id='yirCU'></ins><ul id='yirCU'></ul><sub id='yirCU'></sub></form><legend id='yirCU'></legend><bdo id='yirCU'><pre id='yirCU'><center id='yirCU'></center></pre></bdo></b><th id='yirCU'></th></span></q></dt></tr></i><div id='yirCU'><tfoot id='yirCU'></tfoot><dl id='yirCU'><fieldset id='yirCU'></fieldset></dl></div>
                  本文介绍了沿 A-B 线计算距 A 给定距离的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我非常疯狂地试图计算沿给定线 A-B 的点,距离 A 的给定距离,这样我就可以绘制"两个给定点之间的线.一开始听起来很简单,但我似乎无法正确理解.更糟糕的是,我不明白我哪里出错了.几何(和一般的数学)不是我的强项.

                  I'm going quite mad trying to calculate the point along the given line A-B, at a given distance from A, so that I can "draw" the line between two given points. It sounded simple enough at the outset, but I can't seem to get it right. Worse still, I don't understand where I've gone wrong. Geometry (and math in general) is NOT my strong suite.

                  我已经阅读了类似的问题,并且在 SO 上有答案.事实上,我直接从 Mads Elvheim 的回答中提升了当前对 CalculatePoint 函数的实现:给定起点和终点以及距离,计算沿线的点(加上修正稍后发表评论 - 如果我理解正确的话)因为我独立尝试解决问题的尝试让我无处可去,除了头等舱特快票令人沮丧的地方.

                  I have read similar questions and there answers on SO. In fact I lifted my current implementation of CalculatePoint function directly from Mads Elvheim's answer to: Given a start and end point, and a distance, calculate a point along a line (plus a correction in a later comment - if I understand him correctly) because my indepedent attempts to solve the problem were getting me nowhere, except a first class express ticket frusterpationland.

                  这是我的更新代码(请参阅帖子底部的编辑注释):

                  Here's my UPDATED code (please see the EDIT notes a bottom of post):

                  using System;
                  using System.Drawing;
                  using System.Windows.Forms;
                  
                  namespace DrawLines
                  {
                      public class MainForm : Form
                      {
                          // =====================================================================
                          // Here's the part I'm having trouble with. I don't really understand
                          // how this is suposed to work, so I can't seem to get it right!
                          // ---------------------------------------------------------------------
                  
                          // A "local indirector" - Just so I don't have go down and edit the 
                          // actual call everytime this bluddy thing changes names.
                          private Point CalculatePoint(Point a, Point b, int distance) {
                              return CalculatePoint_ByAgentFire(a, b, distance);
                          }
                  
                          #region CalculatePoint_ByAgentFire
                          //AgentFire: Better approach (you can rename the struct if you need):
                          struct Vector2
                          {
                              public readonly double X;
                              public readonly double Y;
                              public Vector2(double x, double y) {
                                  this.X = x;
                                  this.Y = y;
                              }
                              public static Vector2 operator -(Vector2 a, Vector2 b) {
                                  return new Vector2(b.X - a.X, b.Y - a.Y);
                              }
                              public static Vector2 operator *(Vector2 a, double d) {
                                  return new Vector2(a.X * d, a.Y * d);
                              }
                              public override string ToString() {
                                  return string.Format("[{0}, {1}]", X, Y);
                              }
                          }
                          // For getting the midpoint you just need to do the (a - b) * d action:
                          //static void Main(string[] args)
                          //{
                          //    Vector2 a = new Vector2(1, 1);
                          //    Vector2 b = new Vector2(3, 1);
                          //    float distance = 0.5f; // From 0.0 to 1.0.
                          //    Vector2 c = (a - b) * distance;
                          //    Console.WriteLine(c);
                          /

                2. <small id='M6nNE'></small><noframes id='M6nNE'>

                    <tbody id='M6nNE'></tbody>

                    <tfoot id='M6nNE'></tfoot>
                    1. <i id='M6nNE'><tr id='M6nNE'><dt id='M6nNE'><q id='M6nNE'><span id='M6nNE'><b id='M6nNE'><form id='M6nNE'><ins id='M6nNE'></ins><ul id='M6nNE'></ul><sub id='M6nNE'></sub></form><legend id='M6nNE'></legend><bdo id='M6nNE'><pre id='M6nNE'><center id='M6nNE'></center></pre></bdo></b><th id='M6nNE'></th></span></q></dt></tr></i><div id='M6nNE'><tfoot id='M6nNE'></tfoot><dl id='M6nNE'><fieldset id='M6nNE'></fieldset></dl></div>

                        <bdo id='M6nNE'></bdo><ul id='M6nNE'></ul>
                      • <legend id='M6nNE'><style id='M6nNE'><dir id='M6nNE'><q id='M6nNE'></q></dir></style></legend>