PolyLink
A library to allow manipulation of geometry from within Mathematica
 All Classes Namespaces Files Functions Variables Properties
Vector.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 using Wolfram.NETLink;
7 
8 namespace PolyLink
9 {
10  public struct Vector
11  {
12  private readonly Expr _expr;
13 
14  public Vector(Expr expr) : this()
15  {
16  _expr = expr;
17  }
18 
19  public Expr Expr
20  {
21  get { return _expr; }
22  }
23 
24  public static Vector FromPoints(Expr point1, Expr point2)
25  {
26  return new Vector(MSingle.Eval("{1} - {0}", point1, point2));
27  }
28 
29  public Expr Length
30  {
31  get { return "Sqrt".MsBracket("Dot".MsBracket(new[] {_expr, _expr})); }
32  }
33  }
34 }