計算機圖形學——投影 pygame演示
模型:
def stereoscopic():
x1,x2 = -100,100
y1,y2 = 0,100
z1,z2 = 1,100
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z1), Coordinate(x2,y1,z1),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z2), Coordinate(x2,y1,z2),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z1), Coordinate(x1,y1,z2),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2,y1,z1), Coordinate(x2,y1,z2),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y2, z1), Coordinate(x2, y2, z1), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y2, z1), Coordinate(x2, y2, z1), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y2, z2), Coordinate(x1, y2, z2), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2, y2, z2), Coordinate(x2, y2, z2), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y1, z1), Coordinate(x1, y2, z1), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2, y1, z1), Coordinate(x2, y2, z1), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y1, z2), Coordinate(x1, y2, z2), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2, y1, z2), Coordinate(x2, y2, z2), 2)
stereoscopic()
def stereoscopic2():
x1,x2 = -100,100
y1,y2 = 0,100
z1,z2 = 1,2
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z1), Coordinate(x1,y2,z1),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2,y1,z1), Coordinate(x2,y2,z1),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z1), Coordinate(x2,y1,z1),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y2,z1), Coordinate(x2,y2,z1),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z2), Coordinate(x1,y2,z2),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2,y1,z2), Coordinate(x2,y2,z2),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y1,z2), Coordinate(x2,y1,z2),2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1,y2,z2), Coordinate(x2,y2,z2),2)
#
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y1, z1), Coordinate(x1, y1, z2), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x1, y2, z1), Coordinate(x1, y2, z2), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2, y1, z1), Coordinate(x2, y1, z2), 2)
pygame.draw.line(screen, (1, 1, 1), Coordinate(x2, y2, z1), Coordinate(x2, y2, z2), 2)
# stereoscopic2()
1,平行投影
1.1 :
# 平行投影
# a,b,c = 1,1.2,1 #投影方向
# x = x-a/c*z
# y = y-b/c*z
模型一:正視圖,側(cè)視圖

模型二:正視圖,側(cè)視圖

2,斜投影
2.1 :
#斜平行投影
# xp,yp,zp = 1,1.5,1 #投影方向矢量
# x = x-xp/zp*z
# y = y-yp/zp*z
模型一:正視圖,側(cè)視圖

模型二:正視圖,側(cè)視圖

3,透視投影
3.1 投影:
x/z,y/z
缺點:不能當z等于零時,無法運算。
模型一:正視圖,側(cè)視圖


模型二:正視圖,側(cè)視圖


3.2視距:
n:視距
(x*n)/z
(y*n)/z
缺點:模型一集中于一點,模型二無空間感
模型一:正視圖,側(cè)視圖


模型二:正視圖,側(cè)視圖


3.3視野:

浙公網(wǎng)安備 33010602011771號