using NumSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Con_Num
{
public class MyCover
{
public MyCover(float px, float py, float pz, float x, float y, float z, float a, float b, float r)
{
this.x = x;
this.y = y;
this.z = z;
this.a = a;
this.b = b;
this.r = r;
this.rot = new float[4, 4]
{
{
this.Cos(this.a)*this.Cos(this.b),
this.Cos(this.a)*this.Sin(this.b)*this.Sin(this.r)-this.Sin(this.a)*this.Cos(this.r),
this.Cos(this.a)*this.Sin(this.b)*this.Cos(this.r)+this.Sin(this.a)*this.Sin(this.r),
this.x
},
{
this.Sin(this.a)*this.Cos(this.b),
this.Sin(this.a)*this.Sin(this.b)*this.Sin(this.r)+this.Cos(this.a)*this.Cos(this.r),
this.Sin(this.a)*this.Sin(this.b)*this.Cos(this.r)-this.Cos(this.a)*this.Sin(this.r),
this.y
},
{
-this.Sin(this.b),
this.Cos(this.b)*this.Sin(this.r),
this.Cos(this.b)*this.Cos(this.r),
this.z
},
{
0,
0,
0,
1
},
};
this.line = new float[4, 1] { { px}, { py }, { pz }, { 1 } };
}
#region 字段和属性
private float[,] rot;
public float[,] Rot
{
get { return rot; }
set { rot = value; }
}
private float[,] line;
public float[,] Line
{
get { return line; }
set { line = value; }
}
private float x;
public float X
{
get { return x; }
set { x = value; }
}
private float y;
public float Y
{
get { return y; }
set { y = value; }
}
private float z;
public float Z
{
get { return z; }
set { z = value; }
}
private float px;
public float Px
{
get { return px; }
set { px = value; }
}
private float py;
public float Py
{
get { return py; }
set { py = value; }
}
private float pz;
public float Pz
{
get { return pz; }
set { pz = value; }
}
private float a;
public float A
{
get { return a; }
set { a = value; }
}
private float b;
public float B
{
get { return b; }
set { b = value; }
}
private float r;
public float R
{
get { return r; }
set { r = value; }
}
#endregion
public float Cos(float angle)
{
return (float)Math.Round(Math.Cos(angle * 1.00 * (Math.PI) / 180), 5);
}
public float Sin(float angle)
{
return (float)Math.Round(Math.Sin(angle * 1.00 * (Math.PI) / 180), 5);
}
public NDArray TestNdArray()
{
float[,] rotMatrix = this.rot;
float[,] pointMatrix = line;
NDArray ndRotMatrix = np.array(rotMatrix);
NDArray ndPointMatrix = np.array(pointMatrix);
return np.matmul(ndRotMatrix, ndPointMatrix);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NumSharp;
namespace Con_Num
{
internal class Program
{
static void Main(string[] args)
{
MyCover myCover = new MyCover(0, 0, 1, 0, 0, 0, 0, 0, 30);
NDArray arr1 = myCover.TestNdArray();
NDArray arrRot = np.array(myCover.Rot);
Console.WriteLine(arr1.ToString());
Console.WriteLine("=================");
Console.WriteLine(arrRot.ToString());
Console.WriteLine("======****===========");
Console.WriteLine(arrRot["1,1:"].ToString());
Console.WriteLine("=================");
Console.WriteLine(arr1["0, 0"].ToString());
Console.WriteLine(arr1["1, 0"].ToString());
Console.WriteLine(arr1["2, 0"].ToString());
Console.ReadKey();
}
}
}