첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ 원을 그리기 위한 좌표들을 계산해서 리스트로 반환하는 방법을 보여준다.

 

▶ 원형 Point 리스트 구하기 예제 (C#)

using System.Collections.Generic;
using System.Windows;

// 중심점 (300, 300), 반지름 100인 크기의 원에서 30도 간격의 원형 Point 리스트를 구한다.
List<Point> circularPointList = GetCircularPointList(new Point(300d, 300d), 100d, 30d);

 

▶ 원형 Point 리스트 구하기 (C#)

using System;
using System.Collections.Generic;
using System.Windows;

#region 원형 Point 리스트 구하기 - GetCircularPointList(centerPoint, radius, stepAngle)

/// <summary>
/// 원형 Point 리스트 구하기
/// </summary>
/// <param name="centerPoint">중심점</param>
/// <param name="radius">반경</param>
/// <param name="stepAngle">단계 각도</param>
/// <returns>원형 Point 리스트</returns>
public List<Point> GetCircularPointList(Point centerPoint, double radius, double stepAngle)
{
    List<Point> list = new List<Point>();

    for(double i = 0d; i < 360d; i += stepAngle)
    {
        double radian = Math.PI * i / 180d;

        double x = centerPoint.X + radius * Math.Cos(radian);
        double y = centerPoint.Y + radius * Math.Sin(radian);

        list.Add(new Point(x, y));
    }

    return list;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요