Tudományos Szieszta

Földrajz és Környezettudományi Intézet

Varázstorony

(Természettudományi Pályaorientációs és Módszertani Központ)

Külső kapcsolatok

FutureRFID - Az RFID/NFC technológia továbbfejlesztési lehetőségei az "Internet of Things" koncepciói mentén - TÁMOP pályázat
Alkalmazható természettudományok oktatása a Tudásalapú Társadalomban - TÁMOP pályázat
EKF TTK Mesterképzés a Tudásalapú Társadalom szolgálatában - TÁMOP pályázat

de Casteljau algoritmus (C#)

$\bf P_{i,j}=(1-t)P_{i-1,j}+tP_{i-1,j+1} \cases{i=1,2,...,n \cr j=0,1,...,n-i}$
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace casteljau { public partial class Form1 : Form { Bitmap image; Graphics g; List points = new List(); Color color = Color.Yellow; public Form1() { InitializeComponent(); image = new Bitmap(pictureBox1.Width, pictureBox1.Height); g = Graphics.FromImage(image); pictureBox1.Image = image; } #region DRAW METHOD private void drawCasteljau(List list) { Point tmp; for (double t = 0; t <= 1; t += 0.001) { tmp = getCasteljauPoint(points.Count-1, 0, t); image.SetPixel(tmp.X, tmp.Y, color); } } private Point getCasteljauPoint(int r, int i, double t) { if(r == 0) return points[i]; Point p1 = getCasteljauPoint(r - 1, i, t); Point p2 = getCasteljauPoint(r - 1, i + 1, t); return new Point((int) ((1 - t) * p1.X + t * p2.X), (int) ((1 - t) * p1.Y + t * p2.Y)); } #endregion #region EVENT HANDLERS private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { points.Add(e.Location); //g.Clear(pictureBox1.BackColor); //g.DrawLines(new Pen(color), points.ToArray()); //pictureBox1.Refresh(); } private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e) { points.Add(e.Location); //kirajzolas drawCasteljau(points); pictureBox1.Refresh(); points.Clear(); } #endregion } }

Languages

Belépés

nEtSZKÖZKÉSZLET

TTK logo

Regionális Tudásközpont

International Conference on Applied Informatics