การคำนวณพื้นที่และเส้นรอบวงของวงกลม
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); | |
} | |
} |