Reputation: 33
I need a double[] and I have a Point3d or a Vector3d. How can I convert a Point or a Vector to a double[]? I create the Point and the Vector with following Code:
Point3d pos1 = new Point3d();
Point3d pos2 = new Point3d();
GetPosition(out pos1, out pos2);
Vector3d a = new Vector3d(pos1.X, pos1.Y, pos1.Z);
double[] move_mapped = new double[3];
Upvotes: 2
Views: 1552
Reputation: 43886
As simple as you instantiated the Vector3d
:
double[] move_mapped = new double[] {pos1.X, pos1.Y, pos1.Z};
or with the shorter array initializer
double[] move_mapped = {pos1.X, pos1.Y, pos1.Z};
Upvotes: 2
Reputation: 726619
You can use []
initializer syntax, like this:
double[] move_mapped = new double[] {
pos1.X, pos1.Y, pos1.Z
};
The same syntax works for Vector3d
. You can also use a "shortcut" syntax:
var move_mapped = new[] {a.X, a.Y, a.Z};
Upvotes: 2