Cálculo da área e circunferência dos círculos
Contents
[
Hide
]Como calcular a área e a circunferência dos círculos
Problema: Como calcular a área e a circunferência dos círculos (CADNET-1153).
Dicas: Para fazer isso, obtenha o raio de CadEntityTypeName.CIRCLE das entidades e use a fórmula “2 * Math.PI * radius”.
Exemplo:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (CadBaseEntity entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.CIRCLE) | |
{ | |
double radius = ((CadCircle)entity).Radius; | |
System.Console.WriteLine("Circumference= " + 2 * Math.PI * radius); | |
System.Console.WriteLine("Area= " + Math.PI * radius * radius); | |
} | |
} |