问题描述
我对 3D 表示越来越熟悉。我想检查一组三变量数据点是否落在特定区域内。对于高斯数据,这可以使用以下方法轻松完成:
while menu:
clock.tick(60)
if game_over == 2: #game menu
start_time = pygame.time.get_ticks()
screen.blit(bgmenu,(0,0)) #draw background
keys = pygame.key.get_pressed()
start_buttons(presentskin)
mx,my = pygame.mouse.get_pos() #gets the mouse postion
screen.blit(arrow_left,(200,440))
screen.blit(arrow_right,(330,440))
screen.blit(arrow_left,(170,740))
screen.blit(arrow_right,(360,740))
if skin == 14:
skin = 1
if skin == 0:
skin = 13
if skin == 16 or skin == 18:
skin = 1
for event in pygame.event.get():
if mx >= 600 and mx <= 850 and my >= 0 and my <= 20 and event.type == pygame.MOUSEBUTTONUP: #gets x and y of mouse to check if it is on the button
skin = 17
music = pygame.mixer.music.load(f'newgameimg/sounds/music10.wav')
pygame.mixer.music.play(-1)
if mutee == 1:
pygame.mixer.music.unpause()
elif mutee == 0:
pygame.mixer.music.pause()
if keys[pygame.K_ESCAPE]: #game quit
menu = False
if mx >= 225 and mx <= 445 and my >= 250 and my <= 350 and event.type == pygame.MOUSEBUTTONUP: #gets x and y of mouse to check if it is on the button
#this code starts the game
score = 0
speedcost = 10
speeds = 1
coffeecost = 10
coffees = 1
coffeefallspeed = 2.5
speed = playerspeed
y = 595
x = 25
xx = random.randrange(50,600)
xy = random.randrange(-300,-100)
anvilx = random.randrange(50,600)
anvily = random.randrange(-300,-100)
coffeeaddspeed = 1
#spawns the clouds
cloudx = []
cloudy = []
cloudimage = []
cloudx_change = []
for i in range(num_of_clouds):
cloudimage.append(pygame.image.load("newgameimg/bg/cloud.png"))
cloudx.append(random.randrange(-200,700))
cloudy.append(random.randrange(10,300))
cloudx_change.append(1)
game_over = 0
enemyx = 998
enemyspeedup = 0
isJump = False
coffeeimage = []
coffeex = []
coffeey = []
coffeey_change = []
num_of_coffee = 1
for i in range(num_of_coffee):
coffeeimage.append(pygame.image.load("newgameimg/coffee/coffee_bean1.png"))
coffeex.append(random.randrange(0,600))
coffeey.append(random.randrange(-250,-45))
coffeey_change.append(coffeefallspeed)
if mx >= 480 and mx <= 633 and my >= 720 and my <= 785 and event.type == pygame.MOUSEBUTTONUP: #quit button
menu = False
if mx >= 65 and mx <= 109 and my >= 739 and my <= 788 and event.type == pygame.MOUSEBUTTONUP or keys[pygame.K_m]: #this is for muting the game music
if mutee == 1:
mutee = 0
muteorunmute = mutepng
pygame.mixer.music.pause()
elif mutee == 0:
mutee = 1
muteorunmute = unmutepng
pygame.mixer.music.unpause()
if mx >= 245 and mx <= 263 and my >= 442 and my <= 477 and event.type == pygame.MOUSEBUTTONUP or keys[pygame.K_LEFT] or keys[pygame.K_a]: #changes skin
skin = skin - 1
if skin < 1:
skin = 13
if mx >= 367 and mx <= 394 and my >= 442 and my <= 477 and event.type == pygame.MOUSEBUTTONUP or keys[pygame.K_RIGHT] or keys[pygame.K_d]: #changes skin
skin = skin + 1
if skin > 13:
skin = 1
#song changer
if mx >= 405 and mx <= 421 and my >= 742 and my <= 777 and event.type == pygame.MOUSEBUTTONUP: #music chooser
song += 1
if song == 6:
song = 1
music = pygame.mixer.music.load(f'newgameimg/sounds/music{song}.wav')
pygame.mixer.music.play(-1)
if mx >= 215 and mx <= 234 and my >= 742 and my <= 777 and event.type == pygame.MOUSEBUTTONUP: #music chooser
song -= 1
if song == 0:
song = 4
music = pygame.mixer.music.load(f'newgameimg/sounds/music{song}.wav')
pygame.mixer.music.play(-1)
playerturn += 1
if playerturn <= 50:
presentskin = pygame.image.load(f'newgameimg/players/main{skin}.png')
elif playerturn >= 50:
leftskin = pygame.image.load(f'newgameimg/players/main{skin}.png')
presentskin = pygame.transform.flip(leftskin,True,False)
if playerturn >= 100:
playerturn = 0
screen.blit(presentskin,(270,400))
pygame.display.update()
但是,我如何手动执行此操作?有一个叫做 library(ptinpoly) 的 R 包可以这样做,但是它需要一个三角形网格,我不知道如何获得这些三变量网格点的三角形网格。
data = cbind(rnorm(1000),rnorm(1000),rnorm(1000))
inside = data[,1]^2+data[,2]^2 + data[,3]^2 <= qchisq(0.95,3)
which(inside==T)
有什么线索吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)