How can I represent a vector equation of a line segment in C++?

后端 未结 6 1938
青春惊慌失措
青春惊慌失措 2021-01-19 17:59

I am working with computer graphics.

I would like to represent a line with two end points, and, then I would like my Line2d class to have a method that

6条回答
  •  醉酒成梦
    2021-01-19 18:09

    There are many forms of line representation.

    If you mean line (not segment), then, probably, you'll find convenient to use class/structure, containing BasePoint and UnitDirectionVector.

    For line segments, choose between (Point pt0, Point pt1) form, and, (Point pt, Vector v = pt1 - pt0) form.

    The second one is more suitable for parametric approach like, X = P0.X + t * D.X etc.

提交回复
热议问题