2014年1月18日土曜日

vpython オブジェクトのコピー




























# coding: UTF-8
from visual import *
import window_copy

scene1 = display(title='old_display', x=0, y=0)
#myrod = cylinder(pos=(0,2,1), axis=(5,0,0), radius=1)
mybox = box(pos=(0,2,1), length=5, height=1, width=2)

pointer1 = arrow(pos=(0,0,0), axis=(7,0,0), shaftwidth=0.1 ,color=color.white)
#x軸 白
pointer2 = arrow(pos=(0,0,0), axis=(0,7,0), shaftwidth=0.1 ,color=color.blue)
#y軸 青
pointer3 = arrow(pos=(0,0,0), axis=(0,0,7), shaftwidth=0.1 ,color=color.red)
#z軸 赤

#myrod.rotate(angle=pi/2.0, axis=(0,1,0))
#mybox.rotate(angle=pi/2.0, axis=(0,1,0))
#pi/2.0 単位はラジアン 90°回転

scene2 = display(title='new_display', x=450, y=0)
#scene2.select()
#pointer1 = arrow(pos=(0,0,0), axis=(7,0,0), shaftwidth=0.1 ,color=color.white)
#window_copy.clone_universe(scene2, scene)

#new_pointer1 = pointer1.__copy__(display=scene2)

print '****** scene1 ******'
for obj in scene1.objects:
    print obj
    obj.__copy__(display=scene2)
print '****** scene2 ******'
for obj in scene2.objects:
    print obj
    if obj.__class__ == box:
        mybox2 = obj

ang = 0.1
while True:
    mybox.rotate(angle=ang, axis=(0,1,0))
    mybox2.rotate(angle=ang, axis=(0,1,0))

0 件のコメント:

コメントを投稿

About

参加ユーザー

連絡フォーム

名前

メール *

メッセージ *

ページ

Featured Posts