private List <double> xy(double r, double s, List <List <Node> > CPs) { List <double> xys = new List <double>(); xys.Add(0); xys.Add(0); for (int i = 0; i != NurbsX.Count; ++i) { for (int j = 0; j != NurbsY.Count; ++j) { double NurbsR = NurbsX.R(0, i, r) * NurbsY.R(0, j, s); xys[0] += NurbsR * CPs[i][j].x; xys[1] += NurbsR * CPs[i][j].y; } } return(xys); }
public Matrix <double> N(double r, double s) { List <double> Row1 = new List <double>(); List <double> Row2 = new List <double>(); foreach (Node CP in Nodes) { double Ni = NurbsX.R(0, CP.n / NurbsY.Count, r) * NurbsY.R(0, CP.n % NurbsY.Count, s); Row1.Add(Ni); Row1.Add(0); Row2.Add(0); Row2.Add(Ni); } double[][] Rows = new double[2][]; Rows[0] = Row1.ToArray(); Rows[1] = Row2.ToArray(); return(Matrix <double> .Build.DenseOfRowArrays(Rows)); }
private void button1_Click(object sender, EventArgs e) { BasicForm.Input = textBox1.Text; string[] Blocks = BasicForm.Input.Split('#'); //Order of NURBS int pX = Convert.ToInt32(Blocks[1].Split('\r')[1].Split('=')[1]); int pY = Convert.ToInt32(Blocks[1].Split('\r')[2].Split('=')[1]); //Knot Vector List <double> KnotVectorX = new List <double>(Array.ConvertAll(Blocks[2].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i))); List <double> KnotVectorY = new List <double>(Array.ConvertAll(Blocks[2].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i))); HashSet <double> NodeX = new HashSet <double>(KnotVectorX); HashSet <double> NodeY = new HashSet <double>(KnotVectorY); //Weights List <double> WeightsX = new List <double>(Array.ConvertAll(Blocks[3].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i))); List <double> WeightsY = new List <double>(Array.ConvertAll(Blocks[3].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i))); //Contorl Point List <double> CPx = new List <double>(Array.ConvertAll(Blocks[4].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i))); List <double> CPy = new List <double>(Array.ConvertAll(Blocks[4].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i))); //Nurbs NurbsShapeFunction NurbsX = new NurbsShapeFunction(KnotVectorX, WeightsX); NurbsShapeFunction NurbsY = new NurbsShapeFunction(KnotVectorY, WeightsY); List <double> DrawPx = new List <double> { }; List <double> DrawPy = new List <double> { }; foreach (double x in NodeX) { for (double y = KnotVectorY[0]; y < KnotVectorY.Last(); y += KnotVectorY.Last() / 50) { double tmpx = 0, tmpy = 0; int k = 0; for (int j = 0; j != WeightsY.Count; ++j) { for (int i = 0; i != WeightsX.Count; ++i) { double NurbsR = NurbsX.R(0, pX, i, x) * NurbsY.R(0, pY, j, y); tmpx += NurbsR * CPx[k]; tmpy += NurbsR * CPy[k]; ++k; } } DrawPx.Add(tmpx); DrawPy.Add(tmpy); } } /* * for (double x = KnotVectorX.Min(); x < KnotVectorX.Max(); x += KnotVectorX.Max() / 500) * for (double y = KnotVectorY.Min(); y < KnotVectorY.Max(); y += KnotVectorY.Max() / 50) * { * double tmpx = 0, tmpy = 0; * int k = 0; * for (int j = 0; j != WeightsY.Count; ++j) * for (int i = 0; i != WeightsX.Count; ++i) * { * double NurbsR = NurbsX.R(0, pX, i, x) * NurbsY.R(0, pY, j, y); * tmpx += NurbsR * CPx[k]; * tmpy += NurbsR * CPy[k]; ++k; * } * DrawPx.Add(tmpx); * DrawPy.Add(tmpy); * } */ List <List <double> > DrawP = new List <List <double> > { DrawPx, DrawPy }; BasicForm.bmp[1] = new Bitmap(551, 551); Graphics g = Graphics.FromImage(BasicForm.bmp[1]); this.Close(); }