0% found this document useful (0 votes)
34 views5 pages

Programa Class: Using Using Using Using Namespace Class Double Public Void Double Double Double

The document contains code for several classes in C# that define geometric shapes and calculate their properties. The classes include Triangle, Cylinder, Parallelepiped, and Cone. Methods are defined to calculate properties like area, volume, and side lengths given input dimensions. Additional code shows an example of using the Math.Sin function to plot a sine curve by connecting points on the curve.

Uploaded by

Fabian Padilla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

Programa Class: Using Using Using Using Namespace Class Double Public Void Double Double Double

The document contains code for several classes in C# that define geometric shapes and calculate their properties. The classes include Triangle, Cylinder, Parallelepiped, and Cone. Methods are defined to calculate properties like area, volume, and side lengths given input dimensions. Additional code shows an example of using the Math.Sin function to plot a sine curve by connecting points on the curve.

Uploaded by

Fabian Padilla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Programa class

using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace WindowsFormsApplication3 { class triangulo { double a, b, c, A, B, C; public void idatos(double pa, double pb, double pC) { a = pa; b = pb; C = pC; } public double calc_c() { c = Math.Pow((a * a + Math.Pow(b, 2) - 2 * a * b * Math.Cos(C * 0.017453)), 0.5); return c; } public double calc_A() { A = (180 / 3.14159) * (Math.Asin(a * Math.Sin(C * 0.017453) / c)); return A; } public double calc_B() { B = 180 - A - C; return B; } //2 public void idato(double pa, double pB, double pC) { a = pa; B = pB; C = pC; } public double calc_A2() { A = (180 - C - B); return A; } public double calc_c2() { c = ((a * Math.Sin(C * 0.017453)) / Math.Sin(A * 0.017453)); return c; } public double calc_b() { b = ((c * Math.Sin(B * 0.017453)) / Math.Sin(C * 0.017453)); return b; } }

class Ccilindr { double h, r, a, v; public void idatos(double pH, double pR) { h = pH; r = pR; } public double calc_a() { a = (2 * 3.141593 * r) * (h + r); return a; } public double calc_v() { v = 3.141593 * r * r * h; return v; } } class paralelepipedo { double h, a, v, V, m; public void idatos(double pH, double pR) { h = pH; v = pR; } public double calc_a() { a = (v / h); return a; } public double calc_V() { V = ((2 * a * m) + (2 * a * h) + (2 * m * h)); return V; } } class Ccono1 { double h, r, a, v, g; public void idatos(double pH, double pR) { h = pH; r = pR; } public double calc_a() { a = (3.141593 * r) * (g + r);

return a; } public double calc_v() { v = (3.141593 * r * r * h) / 3; return v; }

} }

####################3funcion seno
using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms;

namespace WindowsApplication27 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //variables double x0, y0, x1, y1; double xscale0, yscale0, xscale1, yscale1; double i; int xp0, yp0, xp1, yp1; //plumas Pen plumA Pen plumB Pen plumC Pen plumD Pen plumE

= = = = =

new new new new new

Pen(Color.Blue, 1); Pen(Color.Red, 1); Pen(Color.Green, 1); Pen(Color.Black, 1); Pen(Color.White, 1);

//ejes de coordenadas Graphics eje = CreateGraphics(); eje.DrawLine(plumB, 100, 150, 500, 150); eje.DrawLine(plumC, 120, 10, 120, 300); //curva seno(x) Graphics segmento = CreateGraphics(); for (i = 0; i < 180; i++) { //primer punto

x0 = 2 * i; x0 = 0.017453 * x0; //a radianes y0 = Math.Sin(x0); xscale0 = 120.0 + 50.0 * x0; yscale0 = 150.0 - 100.0 * y0; xp0 = (Int32)xscale0; //operador de moldeado yp0 = (Int32)yscale0; //segundo punto x1 = 2 * (i + 1); x1 = 0.017453 * x1; y1 = Math.Sin(x1); xscale1 = 120.0 + 50.0 * x1; yscale1 = 150.0 - 100.0 * y1; xp1 = (Int32)xscale1; yp1 = (Int32)yscale1; //segmento para trazar la curva segmento.DrawLine(plumA, xp0, yp0, xp1, yp1); } } } Animation using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms;

namespace WindowsApplication27 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //variables double x0, y0, x1, y1; double xscale0, yscale0, xscale1, yscale1; double i; int xp0, yp0, xp1, yp1; //plumas Pen plumA Pen plumB Pen plumC Pen plumD Pen plumE

= = = = =

new new new new new

Pen(Color.Blue, 1); Pen(Color.Red, 1); Pen(Color.Green, 1); Pen(Color.Black, 1); Pen(Color.White, 1);

//ejes de coordenadas Graphics eje = CreateGraphics(); eje.DrawLine(plumB, 100, 150, 500, 150); eje.DrawLine(plumC, 120, 10, 120, 300);

//curva seno(x) Graphics segmento = CreateGraphics(); for (i = 0; i < 180; i++) { //primer punto x0 = 2 * i; x0 = 0.017453 * x0; //a radianes y0 = Math.Sin(x0); xscale0 = 120.0 + 50.0 * x0; yscale0 = 150.0 - 100.0 * y0; xp0 = (Int32)xscale0; //operador de moldeado yp0 = (Int32)yscale0; //segundo punto x1 = 2 * (i + 1); x1 = 0.017453 * x1; y1 = Math.Sin(x1); xscale1 = 120.0 + 50.0 * x1; yscale1 = 150.0 - 100.0 * y1; xp1 = (Int32)xscale1; yp1 = (Int32)yscale1; //segmento para trazar la curva segmento.DrawLine(plumA, xp0, yp0, xp1, yp1); } } } }

You might also like