Math Pro 數學補給站's Archiver

凡走過必留下痕跡,
所有的經驗都有它的價值。

bugmens 發表於 2022-1-27 21:15

原問題[url]https://math.pro/db/viewthread.php?tid=2317&page=3#pid14966[/url]

[img]https://math.pro/db/attachment.php?aid=6187&k=3b1e03966a8a95068a58d42918c42237&t=1643289223&noupdate=yes[/img]

[url=https://math.pro/db/attachment.php?aid=6188&k=dfe495cdf13fbf77e002aa2c25308a72&t=1643289223]SketchUp檔下載[/url]

bugmens 發表於 2023-1-5 19:25

原問題[url]https://math.pro/db/viewthread.php?tid=3500&page=2#pid22566[/url]

[img]https://math.pro/db/attachment.php?aid=6513&k=778b4a0f19bcb6ae1a000f9b11516877&t=1672917750&noupdate=yes[/img]

[url=https://math.pro/db/attachment.php?aid=6514&k=14d1ce50bbbb8d58ba57582b256133ec&t=1672917750]SketchUp檔下載[/url]

bugmens 發表於 2023-12-16 11:46

原問題[url]https://math.pro/db/viewthread.php?tid=3508&page=1#pid22993[/url]

Keyframe Animation 1.6只支援元件移動動畫功能,需安裝Keyframe Animation 2.5才有元件縮放大小動畫功能。
[url]https://regular-polygon.com/keyframe-animation/download/[/url]

[img]https://math.pro/db/attachment.php?aid=6828&k=73fca9acf4e69f35033a0c2795851324&t=1702697920&noupdate=yes[/img]

[url=https://math.pro/db/attachment.php?aid=6829&k=91161c3b8f0b5f998397d869a83d1e1a&t=1702697920]SketchUp檔下載[/url]

bugmens 發表於 2024-3-9 08:39

原問題[url]https://math.pro/db/viewthread.php?tid=3752&page=1#pid25174[/url]

[img]https://math.pro/db/attachment.php?aid=6877&k=42bf01e0bdc3f532efcddbf702c08e3a&t=1709944625&noupdate=yes[/img]

[url=https://math.pro/db/attachment.php?aid=6878&k=5b7ea663b04982904d0f57e1ccf3d758&t=1709944625]SketchUp檔下載[/url]

bugmens 發表於 2024-11-24 04:16

原問題[url]https://math.pro/db/viewthread.php?tid=3898&page=1#pid26489[/url]

使用SketchUp Ruby Code Editor編輯程式碼
[url]https://alexschreyer.net/projects/sketchup-ruby-code-editor/[/url]
[img]https://i0.wp.com/alexschreyer.net/wp-content/uploads/2010/02/2017-07-07_11-46-57.jpg?resize=1200%2C644&ssl=1[/img]

SketchUp的ruby語法介紹[url]https://ruby.sketchup.com/Sketchup.html[/url]

程式碼
# Default code
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
###########先產生動畫所需的各個群組###########
#半徑10的圓
circle=ent.add_circle [0,0,0],[0,0,1],10
#將圓的各頂點形成面
cv_arr = []
circle.each do |c|
  cv_arr << c.vertices[0]
end
face = ent.add_face cv_arr
#新增一個圓的群組
group=ent.add_group(face.all_connected)
group.name="圓"

#新增x軸群組
xline=ent.add_line([-10,0,0],[10,0,0])
group=ent.add_group(xline)
group.name="x軸"
group.visible=false

#新增積分體積群組
pt1=[-10,0,0]
pt2=[-9,Math.sqrt(100-(-9)**2),0]
pt3=[-9,-Math.sqrt(100-(-9)**2),0]
pt4=[-9,0,Math.sqrt(300-3*(-9)**2)]
face=ent.add_face pt1,pt4,pt2
edges=face.edges
for edge in edges
  edge.visible=false#將邊隱藏
end
#增加為三角形面
face=ent.add_face pt1,pt4,pt3
edges=face.edges
for edge in edges
  edge.visible=false#將邊隱藏
end

#新增正三角形群組
for i in -9..9
  x=i
  pt1=[i,Math.sqrt(100-i**2),0]
  pt2=[i,-Math.sqrt(100-i**2),0]
  pt3=[i,0,Math.sqrt(300-3*i**2)]
  
  group = ent.add_group
  group.entities.add_curve [pt1,pt2,pt3,pt1]
  group.name="正三角形x=#{i}"
  group.visible=false
  if x==9
    break
  end
  pt4=[i+1,Math.sqrt(100-(i+1)**2),0]
  pt5=[i+1,-Math.sqrt(100-(i+1)**2),0]
  pt6=[i+1,0,Math.sqrt(300-3*(i+1)**2)]
  #增加為四邊形面
  face1=ent.add_face pt1 , pt3 , pt6,pt4
  edges=face1.edges
  for edge in edges
    edge.visible=false#將邊隱藏
  end
  #增加為四邊形面
  face2=ent.add_face pt2 , pt3 , pt6,pt5
  edges=face2.edges
  for edge in edges
    edge.visible=false#將邊隱藏
  end  
end

pt1=[10,0,0]
pt2=[9,Math.sqrt(100-9**2),0]
pt3=[9,-Math.sqrt(100-9**2),0]
pt4=[9,0,Math.sqrt(300-3*9**2)]
face=ent.add_face pt1,pt2,pt4
edges=face.edges
for edge in edges
  edge.visible=false#將邊隱藏
end
face=ent.add_face pt1,pt3,pt4
edges=face.edges
for edge in edges
  edge.visible=false#將邊隱藏
end
group = ent.add_group(face.all_connected)
group.name="積分體積"
group.visible=false

#複製原本的積分體積群組後再手動刪除一半的面
group2=group.copy
group2.name="積分體積(刪除一半的面)"
group2.visible=false

#新增直角三角形群組
pt2=[-4,Math.sqrt(100-(-4)**2),0]
group = ent.add_group
group.entities.add_line [0,0,0],pt2
group.name="直角三角形"
group.visible=false
###########新增場景,依序顯示各個群組###########
#顯示圓
ent[0].visible=true
pages=mod.pages.add "場景號1"
#顯示x軸
ent[1].visible=true
pages=mod.pages.add "場景號2"

for i in 2..20
  ent[ i ].visible=true#顯示正三角形
  pages=mod.pages.add "場景號#{i+1}"
end

#顯示積分體積
ent[21].visible=true
pages=mod.pages.add "場景號22"

#只留下x=-6的正三角形,其餘正三角形隱藏
for i in 2..6
  ent[ i ].visible=false
end
for i in 8..20
  ent[ i ].visible=false
end
pages=mod.pages.add "場景號23"
#改顯示積分體積(刪除一半的面)
ent[21].visible=false
ent[22].visible=true
pages=mod.pages.add "場景號24"

#顯示直角三角形
ent[23].visible=true
pages=mod.pages.add "場景號25"

[img]https://math.pro/db/attachment.php?aid=7276&k=291359762261109fd50282424d0e06c1&t=1732392109&noupdate=yes[/img]

[url=https://math.pro/db/attachment.php?aid=7277&k=7e0f3972adc17d10feb1cce550908051&t=1732392109]SketchUp檔下載[/url]

頁: 1 2 [3]

論壇程式使用 Discuz! Archiver   © 2001-2022 Comsenz Inc.