static void Main(string[] args) { double A, B, C, pi = 3.14159; double TRIANGLE, CIRCLE, TRAPEZIUM, SQUARE, RECTANGLE; string[] values = Console.ReadLine().Split(' '); A = double.Parse(values[0], CultureInfo.InvariantCulture); B = double.Parse(values[1], CultureInfo.InvariantCulture); C = double.Parse(values[2], CultureInfo.InvariantCulture); TRIANGLE = A * C / 2.0; CIRCLE = pi * C * C; TRAPEZIUM = (A + B) / 2.0 * C; SQUARE = B * B; RECTANGLE = A * B; Console.WriteLine("TRIANGULO: " + TRIANGLE.ToString("F3", CultureInfo.InvariantCulture)); Console.WriteLine("CIRCULO: " + CIRCLE.ToString("F3", CultureInfo.InvariantCulture)); Console.WriteLine("TRAPEZIO: " + TRAPEZIUM.ToString("F3", CultureInfo.InvariantCulture)); Console.WriteLine("QUADRADO: " + SQUARE.ToString("F3", CultureInfo.InvariantCulture)); Console.WriteLine("RETANGULO: " + RECTANGLE.ToString("F3", CultureInfo.InvariantCulture)); }
public int OptimizingLevel = 10; //优化等级,数字越大优化级别越高,越容易失真 public void Set(DXFStructure dxf, CIRCLE item, float ScaleX = 1, float ScaleY = 1) { var goLayer = GoView.Content.GetLayer(item.C8); if (goLayer != null) { lr.material = goLayer.LayerMaterial; ZoomAdjust = goLayer.ZoomAdjust; } float R = (float)item.C40; Diameter = R * 2; //计算一个圆需要多少线条 int resolution = (int)item.C40 / OptimizingLevel; if (resolution > MaxResolution) { resolution = MaxResolution; } if (resolution < MinResolution) { resolution = MinResolution; } lr.SetVertexCount(resolution + 1); for (int i = 0; i < resolution; ++i) { lr.SetPosition(i, new Vector3((R * Mathf.Cos(2 * Mathf.PI / resolution * i) + (float)item.C10) * ScaleX, (R * Mathf.Sin(2 * Mathf.PI / resolution * i) + (float)item.C20) * ScaleY, 0)); } lr.SetPosition(resolution, new Vector3((R * Mathf.Cos(2 * Mathf.PI / resolution * 0) + (float)item.C10) * ScaleX, (R * Mathf.Sin(2 * Mathf.PI / resolution * 0) + (float)item.C20) * ScaleY, 0)); this.gameObject.isStatic = true; }