Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using t3d;
- using punkt;
- namespace WindowsFormsApplication5
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- DoubleBuffered = true;
- }
- private double R = 10, fi = 45, teta = 80;
- diament d1 = new diament(new Punkt(0, 0, 0), Color.Black, Color.White);
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- int szer = ClientRectangle.Width;
- int wys = ClientRectangle.Height;
- double x, y, z;
- double a = Math.PI / 180.0;
- double b = R * Math.Sin(a * teta);
- x = b * Math.Cos(a * fi);
- y = b * Math.Sin(a * fi);
- z = R * Math.Cos(a * teta);
- Punkt obserwator = new Punkt(x,y,z);
- T3d projektor = new T3d(obserwator,0,0,szer,wys,0.5,0,0);
- d1.rysuj(g, ref projektor);
- //Punkt zero = new Punkt(0, 0, 0);
- /*
- Punkt p1 = new Punkt(1, 1, 0);
- Punkt p2 = new Punkt(-1, 1, 0);
- Punkt p3 = new Punkt(1, -1, 0);
- Punkt p4 = new Punkt(-1, -1, 0);
- Punkt p5 = new Punkt(0, 0, Math.Sqrt(5.0));
- Punkt p6 = new Punkt(0, 0, -Math.Sqrt(5.0));
- int xe, ye;
- int xe1, ye1;
- int xe2, ye2;
- int xe3, ye3;
- int xe4, ye4;
- int xe5, ye5;
- int xe6, ye6;
- */
- /*
- if (projektor.punkt_3d(out xe, out ye, zero) && projektor.punkt_3d(out xe1, out ye1, p1) && projektor.punkt_3d(out xe2, out ye2, p2)
- && projektor.punkt_3d(out xe3, out ye3, p3) && projektor.punkt_3d(out xe4, out ye4, p4) && projektor.punkt_3d(out xe5, out ye5, p5)
- && projektor.punkt_3d(out xe6, out ye6, p6))
- {
- int r = 2;
- g.FillEllipse(Brushes.Blue, xe - r, ye - r, 2*r, 2*r);
- g.FillEllipse(Brushes.Blue, xe1 - r, ye1 - r, 2 * r, 2 * r);
- g.FillEllipse(Brushes.Blue, xe2 - r, ye2 - r, 2 * r, 2 * r);
- g.FillEllipse(Brushes.Blue, xe3 - r, ye3 - r, 2 * r, 2 * r);
- g.FillEllipse(Brushes.Blue, xe4 - r, ye4 - r, 2 * r, 2 * r);
- g.FillEllipse(Brushes.Blue, xe5 - r, ye5 - r, 2 * r, 2 * r);
- g.FillEllipse(Brushes.Blue, xe6 - r, ye6 - r, 2 * r, 2 * r);
- g.DrawLine(Pens.Red, xe1, ye1, xe2, ye2);
- g.DrawLine(Pens.Red, xe1, ye1, xe3, ye3);
- g.DrawLine(Pens.Red, xe2, ye2, xe4, ye4);
- g.DrawLine(Pens.Red, xe3, ye3, xe4, ye4);
- g.DrawLine(Pens.Red, xe1, ye1, xe6, ye6);
- g.DrawLine(Pens.Red, xe2, ye2, xe6, ye6);
- g.DrawLine(Pens.Red, xe4, ye4, xe6, ye6);
- g.DrawLine(Pens.Red, xe3, ye3, xe6, ye6);
- g.DrawLine(Pens.Red, xe1, ye1, xe5, ye5);
- g.DrawLine(Pens.Red, xe2, ye2, xe5, ye5);
- g.DrawLine(Pens.Red, xe3, ye3, xe5, ye5);
- g.DrawLine(Pens.Red, xe4, ye4, xe5, ye5);
- }
- */
- }
- private void Form1_Resize(object sender, EventArgs e)
- {
- Invalidate();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- double dfi = 1.0;
- fi += dfi;
- if(fi > 360)
- {
- fi -= 360;
- }
- Invalidate();
- }
- }
- class diament
- {
- private Punkt[] rogi = new Punkt[4];
- private double bok = 0.8;
- private Brush b;
- private Pen p;
- public diament(Punkt p0, Color k1, Color k2)
- {
- double b2 = bok / Math.Sqrt(2);
- rogi[0] = new Punkt(p0.x, p0.y + b2, p0.z + b2);
- rogi[1] = new Punkt(p0.x, p0.y + b2, p0.z - b2);
- rogi[2] = new Punkt(p0.x, p0.y - b2, p0.z - b2);
- rogi[3] = new Punkt(p0.x, p0.y - b2, p0.z + b2);
- b = new SolidBrush(k1);
- p = new Pen(k2);
- }
- public void rysuj(Graphics g, ref T3d projektor)
- {
- Point[] points = new Point[4];
- int[] xe = new int[4];
- int[] ye = new int[4];
- for (int i = 0; i < 4; ++i)
- {
- projektor.punkt_3d(out xe[i], out ye[i], rogi[i]);
- points[i].X = xe[i];
- points[i].Y = ye[i];
- }
- g.FillPolygon(b, points);
- g.DrawPolygon(p, points);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement