public struct vector3d{public double x,y,z;/*...*/}to work with 3-dimensional Euclidean vectors; implement the relevant methods and overload the relevant operators; override
ToString
method.
.x,.y,.z
as
properties.
interface ivector3d
and implement dot- and
vector-product via the interface.
Hints:
vector3d.cs
file and compile it into
a library,
vector3d.dll: vector3d.cs mcs -target:library -out:$@ @<
main
class with the Main
method (which
should prove that your vector3d works as intended) should then be
compiled as
main.exe: main.cs vector3d.dll mcs -target:exe -out:$@ -reference:$(word 2,$^) @<
//constructors public vector3d(double a,double b,double c){x=a;y=b;z=c;}
//operators vector3d operator*(vector3d v, double c){return new vector(c*v.x,c*v.y,c*v.z);} vector3d operator*(double c, vector3d v){/*...*/} vector3d operator+(vector3d u, vector3d v){/*...*/} vector3d operator-(vector3d u, vector3d v){/*...*/} //methods double dot_product(vector3d other){/*...*/} vector3d vector_product(vector3d other){/*...*/} double magnitude(){} /*...*/