■ 나선형 포인트 컬렉션 구하기 예제

----------------------------------------------------------------------------------------------------

using Windows.UI.Xaml.Media;

 

PointCollection collection = GetSpiralPointCollection(1000, 1000, 0, 3600, 3.6, false);

----------------------------------------------------------------------------------------------------

 

■ 나선형 포인트 컬렉션 구하기

----------------------------------------------------------------------------------------------------

using System;

using Windows.Foundation;

using Windows.UI.Xaml.Media;

 

#region 나선형 포인트 컬렉션 구하기 - GetSpiralPointCollection(xCenter, yCenter, startAngle, endAngle, softness, spiralDownEnded)

 

/// <summary>

/// 나선형 포인트 컬렉션 구하기

/// </summary>

/// <param name="xCenter">X 중심점</param>

/// <param name="yCenter">Y 중심점</param>

/// <param name="startAngle">시작 각도</param>

/// <param name="endAngle">종료 각도</param>

/// <param name="softness">정밀도</param>

/// <param name="spiralDownEnded">나선 하단 완료 여부</param>

/// <returns>나선형 포인트 컬렉션</returns>

/// <remarks>

/// 정밀도 : 값이 작을 수도록 정밀해진다.

/// </remarks>

public PointCollection GetSpiralPointCollection(double xCenter, double yCenter, int startAngle, int endAngle, double softness,

    bool spiralDownEnded)

{

    PointCollection collection = new PointCollection();

 

    for(int angle = startAngle; angle < endAngle; angle++)

    {

        double radians = Math.PI * angle / 180;

        double radius  = angle / softness;

        double x       = xCenter + radius * Math.Sin(radians);

        double y       = yCenter + (spiralDownEnded ? radius : -radius) * Math.Cos(radians);

 

        collection.Add(new Point(x, y));

    }

 

    return collection;

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요