728x90
반응형
728x170
▶ PolarPoint.cs
using System;
namespace TestProject
{
/// <summary>
/// 극 좌표
/// </summary>
public class PolarPoint
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 반경 - Radius
/// <summary>
/// 반경
/// </summary>
public double Radius { get; set; }
#endregion
#region 각도 - Angle
/// <summary>
/// 각도
/// </summary>
public double Angle { get; set; }
#endregion
#region X - X
/// <summary>
/// X
/// </summary>
public double X
{
get
{
return Radius * Math.Cos(Angle * Math.PI / 180.0);
}
}
#endregion
#region Y - Y
/// <summary>
/// Y
/// </summary>
public double Y
{
get
{
return Radius * Math.Sin(Angle * Math.PI / 180.0);
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - PolarPoint(radius, angle)
/// <summary>
/// 생성자
/// </summary>
/// <param name="radius">반경</param>
/// <param name="angle">각도 (단위 : 도)</param>
public PolarPoint(double radius, double angle)
{
if(radius < 0.0)
{
throw new ArgumentException("Radius must be non-negative");
}
if((angle < 0) || (angle >= 360.0))
{
throw new ArgumentException("Angle must be in range [0, 360)");
}
Radius = radius;
Angle = angle;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 문자열 구하기 - ToString()
/// <summary>
/// 문자열 구하기
/// </summary>
/// <returns>문자열</returns>
public override string ToString()
{
return string.Format("({0}, {1})", X, Y);
}
#endregion
}
}
728x90
▶ Program.cs
using System;
namespace TestProject
{
/// <summary>
/// 프로그램
/// </summary>
class Program
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 프로그램 시작하기 - Main()
/// <summary>
/// 프로그램 시작하기
/// </summary>
private static void Main()
{
Console.WriteLine(new PolarPoint(0.0, 0.0));
Console.WriteLine(new PolarPoint(1.0, 0.0));
Console.WriteLine(new PolarPoint(1.0, 45.0));
Console.WriteLine(new PolarPoint(1.0, 90.0));
Console.WriteLine(new PolarPoint(1.0, 135.0));
Console.WriteLine(new PolarPoint(1.0, 180.0));
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] USB 케이블 연결 카메라에서 사진 파일 복사하기 (0) | 2021.02.22 |
---|---|
[C#/COMMON] 누겟 설치 : MediaDevices (0) | 2021.02.22 |
[C#/COMMON] Process 클래스 : PowerShell 스크립트 파일 실행하기 (0) | 2021.02.22 |
[C#/COMMON] Process 클래스 : PowerShell 스크립트 실행하기 (0) | 2021.02.22 |
[C#/COMMON] Runspace 클래스 : PowerShell 스크립트 실행하기 (0) | 2021.02.22 |
[C#/COMMON] 3자 컴포넌트 어셈블리 서명하기 (0) | 2021.02.08 |
[C#/COMMON] 반복자(Iterator)를 사용해 텍스트 파일 반대로 읽기 (0) | 2021.02.08 |
[C#/COMMON] 모니터 수 구하기 (0) | 2021.02.08 |
[C#/COMMON] Enum 클래스 : GetValues 정적 메소드를 사용해 열거형 값 배열 구하기 (0) | 2021.02.07 |
[C#/COMMON] WeakReference 클래스 : 약한 참조 사용하기 (0) | 2021.02.07 |
댓글을 달아 주세요