圆的面积和周长计算
Contents
[
Hide
]如何计算圆的面积和周长
问题: 如何计算圆的面积和周长 (CADNET-1153)。
提示: 为此,从实体中获取来自 CadEntityTypeName.CIRCLE 的半径,并使用公式 “2 * Math.PI * radius”。
示例:
This file contains 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); | |
} | |
} |