Young-Hoon의 모든 글

Spherical coordinate system

구면 좌표계

다음의 3가지 요소를 이용하여 3차원 좌표를 결정할 수 있는 체계를 말한다.

3요소 : 반지름(radial distance), 극각(polar angle), 방위각(azimuthal angle)

구면 좌표계의 한 점 P (r, θ, φ) r= radius, θ=polar angle, φ=azimuthal angle 을 3차원 데카르트 공간좌표계로 변환하면 다음과 같다

P (x,y,z) = P(r, θ, φ)
x = r cosφ sinθ
y = r sinφ cosθ
z = r cosθ

https://en.wikipedia.org/wiki/Spherical_coordinate_system

https://github.com/mrdoob/three.js/blob/master/src/math/Spherical.js

three.js 구면좌표계 계산 클래스

C# 생성자와 필드 초기화

https://docs.microsoft.com/ko-kr/archive/blogs/ericlippert/why-do-initializers-run-in-the-opposite-order-as-constructors-part-two

생성자와 필드 초기화 순서가 궁금하여 다음과 같은 예제 코드를 작성했다. 위 링크의 포스트에 비슷한 예제가 있으니 궁금하면 한번 확인해보기 바란다.

class Apple
    {
        public Apple(string text)
        {
            Console.WriteLine(text);
        }
    }

    class Orange
    {
        Apple apple = new Apple("Orange apple");
        Apple apple1 = new Apple("Orange apple1");
        public Orange()
        {
            Console.WriteLine("Orange write");
        }
    }

    class Melon : Orange
    {
        Apple greenApple = new Apple("Melon apple");
        Apple blueApple = new Apple("Blue melon apple");
        public Melon()
        {
            Console.WriteLine("Melon write");
        }

        public void Shape() 
        {
            Console.WriteLine("melon is sphere");
        }
    }
 class Program
    {
        static void Main(string[] args)
        {
            new Melon();
        }
    }

결과는 다음과 같다.

초기화 리스트는 derived class -> base class 순으로 그리고 위에서 아래쪽으로 실행 되었다.

하지만 생성자는 base class -> derived class 로 호출되었다.

Javascript에 대한 사소한 궁금증

Q. 문자열 ‘ ‘ 과 ” ” 의 차이

A. 차이 없음.
자바스크립트에서는 String 값을 표현할 때 “”를 사용하는데 C언어 기반 과 자바에서는 큰 따옴표(“) 만 사용해서 자칫 차이점이 있는 것 같은데 조사에 따르면 String을 표현하는 방식일뿐 차이가 없는 것으로 나온다.
참고로 작음 따옴표(‘)와 마찬가지로 억음 부호(backtick – ` ) 도 차이가 없다.
[ref. 클릭]