메뉴 건너뛰기

목록
profile
조회 수 247 댓글 12 예스잼 8 노잼 0

https://youtu.be/DEqXNfs_HhY

이걸 보고 영감을 받아서

파이썬에서도 저런 걸 만들수 있지 않을까 해서 시도해봤음

 

luminosity.png

 

먼저 광량 측정은 평면을 빛에 수직인 평면에 대해 정사영한거니까 광원으로부터 원위 점까지 벡터의 내적으로 각을 구하면 측정가능(아마)

conputer graphic.png

 

프로그램 내의 상황임. 구하고 관찰자가 z축위에 있고 모니터는 xy평면인 상황임

5/15배라는건 잘못적은거

computer graphic .png

 

 

보이는 부분만 모니터에 표시해야하니까 시선벡터와 구의 벡터 내적이 0보다 클때만 보면 됨

그후 구 위의 점 좌표를 x,y,z라 하고

직각삼각형의 닮음에 따라 눈으로부터 xy평면의 거리인 5,

그리고 구 위의 점의 z좌표를 z라 했을 때 x y 좌표는 각각 5/(z+5)배가 됨

 

 

그래서 하루종일 만든 프로그램임

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from math import *
# range함수는 float를 사용못해서 generator를 새로 만듦
def generator(start, end, step):
    result = start
    while result <= end:
        yield result
        result += step
    
coordinates = []
= 5
# 구 위의 점 설정. x^2+y^2+z^2 = r^2 사용을 어떻게 하나 고민하고 있었는데 인터넷에서 답을 얻음
for azimuth in generator(02*pi, 0.05):
    for theta in generator(-pi/2, pi/20.05):
        x = r*cos(theta)*sin(azimuth)
        y = r*sin(theta)
        z = r*cos(theta)*cos(azimuth)
        coordinates.append([x,y,z])
#만들어진 구는 0,0,0에 위치해 있기때문에 좌표들을 z축으로 10만큼 이동해줌
sphere_center = [0,0,10]
for coord in coordinates:
    coord[2+= sphere_center[2]
lcx = int(input('Input light coordinate x:'))
lcy = int(input('Input light coordinate y:'))
lcz = int(input('Input light coordinate z:'))
light_coord = [lcx,lcy,lcz]
sight_coord = [0,0,-5]
sphere_vector = []
light_vector = []
sight_vector = []
#각 점마다 벡터 계산
for coord in coordinates:
    sphere_vector.append([coord[0]-sphere_center[0], coord[1]-sphere_center[1], coord[2]-sphere_center[2]])
    light_vector.append([light_coord[0]-coord[0], light_coord[1]-coord[1], light_coord[2]-coord[2]])
    sight_vector.append([sight_coord[0]-coord[0], sight_coord[1]-coord[1], sight_coord[2]-coord[2]])
cosine = []
#내적으로 코사인값 구하기
for i in range(len(sphere_vector)):
    sv = sphere_vector[i]
    lv = light_vector[i]
    a_dot_b = sv[0]*lv[0+ sv[1]*lv[1+ sv[2]*lv[2]
    abs_a = sqrt(sv[0]*sv[0]+sv[1]*sv[1]+sv[2]*sv[2])
    abs_b = sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2])
    angle = a_dot_b/(abs_a*abs_b)
    cosine.append(angle)
#광량 계산 0-1사이의 값이 나오게 됨
luminance = []
for cos in cosine:
    if cos >= 0:
        sine = sqrt(1-cos*cos)
        luminance.append(sine)
    else:
        luminance.append(0)
#모니터에 출력할 좌표 계산
output_coordinates = []
for i in range(len(sphere_vector)):
    sv = sphere_vector[i]
    siv = sight_vector[i]
    a_dot_b = sv[0]*siv[0]+sv[1]*siv[1]+sv[2]*siv[2]
    if a_dot_b >= 0:
        scale = abs(sight_coord[2])/(coordinates[i][2]-sight_coord[2])
        output_coordinates.append([scale*coordinates[i][0], scale*coordinates[i][1], 0, luminance[i]])
 
xplot = [[],[],[],[],[],[],[],[],[],[],[]]
yplot = [[],[],[],[],[],[],[],[],[],[],[]]
#광량 정도에 따라 좌표들을 나눠서 출력함
for l in output_coordinates:
    lum = round(l[3],1* 10
    xplot[int(lum)].append(l[0])
    yplot[int(lum)].append(l[1])
import matplotlib.pyplot as plt
for i in range(11):
    plt.plot(xplot[i], yplot[i], 'o')
plt.show()
cs

이거 좌표는 다 구했는데 어떻게 출력할지가 막막해서 시간 존나게 날려먹음

사실 생각하고 있었던건 저 스피닝 도넛처럼 캐릭터로 그리드 만들어서 좌표들을 그 그리드 안에 우겨넣어서 ascii글자로 출력하고 싶었는데

많은 시행착오를 거쳐도 도저히 할수가 없었음...

 

그래서 대안을 찾아보다가 matlab을 발견해서 활용하기로 함

 

matlabㅈㄴ 좋은거같음

다음은 결과 사진들임

Figure_1.png

Figure_3.png

 

1010-10.png

위에껀 광점을 7,7,7로 잡은거고 아래사진은 10,10,-10로 잡은것

 

아름답다...


List of Articles
번호 제목 글쓴이 날짜 조회 수 추천
공지 수용소닷컴 이용약관 file asuka 2020.05.16 1362 1
1122 gitlab쓰지 마셈 15 다람쥐 2020.06.11 673 0
1121 Selenium alert_is_present 작동 원리 2 우지챠 2021.01.04 623 1
1120 Microsoft Visual Studio 2022를 사용하여 첫 번째 C++ Windows Form 만들기 9 file 저능아 2023.01.15 389 1
1119 해피해킹 프로2 type-s 사용기 8 file 다람쥐 2020.05.24 333 2
1118 성님들도 서버호스팅 하나 받으셈 14 file 머스크멜론 2021.02.24 331 0
1117 정보) 수용서의 기본소양 1편, 짤검색에 대해서 araboji. 8 file 하루각하 2021.01.06 317 6
1116 RAID5 순차쓰기 성능이 너무 낮음... 1 아메 2021.12.29 247 0
» 오늘 한 프로젝트: 그래픽 광량 표현 12 file 우지챠 2021.01.05 247 8
1114 좆본 IT 취업 가이드 ~ 간략판 ~ 9 抱き枕 2020.07.22 245 6
1113 삭제된 게시글입니다. 노모현 2020.06.03 243 0
1112 -메랜- 고확추출 말폭도 2024.01.24 210 0
1111 키 마우스 매핑 프로그램 만들었음 10 file '`' 2022.08.30 207 6
1110 시발 리눅스 SSH서버 공개키로그인이 왜안되나 했는데 5 file 히마와리 2020.06.21 198 0
1109 스프링에서 파일업로드 개발하는데 왤케 에러나냐 8 阿米娅 2020.08.12 197 0
1108 콤퓨타 ㅍㅌㅊ? 11 file 문향 2020.05.19 194 -1
1107 대학생 때 세웠던 목표를 이뤘음 7 file 마루쉐 2021.09.14 191 10
1106 본인 노트북 자랑해봄 4 file ハンター 2020.05.20 184 0
1105 삭제된 게시글입니다. 스마일 2020.06.12 182 0
1104 삭제된 게시글입니다. 노모현 2020.05.30 175 0
목록
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 57 Next
/ 57