円の面積と周囲の計算
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); | |
} | |
} |