Vector of a line C#

(Hanne Rs 93) #1

I want to find the vector of a input line, how do I do that in C#?


If you know* that your Curves are linear you can cast, or recreate, them as Lines, or directly recreate as Vector3d, like so:

  private void RunScript(List<Curve> L, ref object A, ref object V)
    Curve crv = L[0];
    Vector3d vec = new Vector3d(crv.PointAtEnd - crv.PointAtStart);
    A = crv.PointAtStart;
    V = vec;

// Rolf

* Well, you can recreate them as lines anyway. You can also test “crv.IsLinear” if it matters whether the cruve is linear or not)

(Laurent Delrieu) #3

If you want just line and not curve choose Line as Type Hint

in Line you will have direction as Properties
A Line could be a Curve but a Curve is not always a Line.

(David Rutten) #4

You don’t need to create a new vector at all, the subtraction of two points should already give you a vector.

(Michael Pryor) #5

.Direction would work if the data type was line rather than curve.