Title: 40423119_W17作業
Date: 2017-06-15 11:17
Category: HomeWork
Tags: 期末協同查驗與自評
Author: 40423119

1.solvespace 檔案推送

2.solvespace 2D 繪圖 程式碼

3.子模組建立與運用

4.Solvespace 近端零組件繪圖

5.Solvespace 零件轉入 V-rep

6.期末分組專題

7.上傳 Fossil SCM 倉儲

<!-- PELICAN_END_SUMMARY -->
#1. solvespace 檔案推送

<iframe width="560" height="315" src="https://www.youtube.com/embed/MRbDxwXsouE" frameborder="0" allowfullscreen></iframe>

<iframe src="./../w17/40423119.html" width="800" height="600"></iframe>

#2.solvespace 2D 繪圖 程式碼

<iframe width="560" height="315" src="https://www.youtube.com/embed/W1ERK57jgyA" frameborder="0" allowfullscreen></iframe>

<!-- 導入 Brython 標準程式庫 -->
 <script src="../data/Brython-3.3.1/brython.js"></script>
<script src="../data/Brython-3.3.1/brython_stdlib.js"></script>
 
<!-- 啟動 Brython -->
<script>
window.onload=function(){
// 設定 data/py 為共用程式路徑
brython({debug:1, pythonpath:['./../data/py']});
}
</script>

<!-- 以下實際利用  Brython 繪圖-->
<canvas id="onegear2" width="800" height="600"></canvas>
<div id="onegear_div" width="800" height="20"></div>

<script type="text/python3">
from browser import document as doc
import math
# deg 為角度轉為徑度的轉換因子
deg = math.pi/180.
# 定義 Spur 類別
class Spur(object):
    def __init__(self, ctx):
        self.ctx = ctx
 
# 設定畫線參數 
    def create_line(self, x1, y1, x2, y2, width=3, fill="#54fff6"):
        self.ctx.beginPath()
        self.ctx.lineWidth = width
        self.ctx.moveTo(x1, y1)
        self.ctx.lineTo(x2, y2)
        self.ctx.strokeStyle = fill
        self.ctx.stroke()
    def create_line2(self, x1, y1, x2, y2, width=3, fill="#54ff5f"):
        self.ctx.beginPath()
        self.ctx.lineWidth = width
        self.ctx.moveTo(x1, y1)
        self.ctx.lineTo(x2, y2)
        self.ctx.strokeStyle = fill
        self.ctx.stroke()
    def create_line3(self, x1, y1, x2, y2, width=3, fill="#f354ff"):
        self.ctx.beginPath()
        self.ctx.lineWidth = width
        self.ctx.moveTo(x1, y1)
        self.ctx.lineTo(x2, y2)
        self.ctx.strokeStyle = fill
        self.ctx.stroke()
        

    def Gear(self, midx, midy, rp, n=20, pa=20, color="black"):
        
        rp = 250
        imax = 15
        m=2*rp/n
        a=m
        d=1.25*m
        ra=rp+a

       
        # self.create_line(起點X, 起點Y, 終點X, 終點Y)
        self.create_line2(400.0092358669, 99.7467537143, 251.9547191519, 442.8435006599)
        self.create_line3(400.0092358669, 99.7467537143, 537.4903413459, 440.1127860465)
        self.create_line2(143.0084564396, 393.7995926042, 314.6469023490, 471.0653927376)
        self.create_line3(143.0084564396, 393.7995926042, 202.3690092639, 492.0551734376)
        self.create_line2(202.3690092639, 492.0551734376, 314.6469023490, 471.0653927376)
        self.create_line3(465.4788879723, 480.3190039124, 593.2602222967, 408.9747395441)
        self.create_line2(465.4788879723, 480.3190039124, 567.9291276424, 502.4572906272)
        self.create_line3(567.9291276424, 502.4572906272, 593.2602222967, 408.9747395441)

       
    

        if rd>rb:
            dr = (ra-rd)/imax
        else:
            dr=(ra-rb)/imax
        sigma=math.pi/(2*n)+math.tan(pa*deg)-pa*deg
        for j in range(-9, 10, +1):
            ang=-2.*j*math.pi/n+sigma
            ang2=2.*j*math.pi/n+sigma
            lxd=midx+rd*math.sin(ang2-2.*math.pi/n)
            lyd=midy-rd*math.cos(ang2-2.*math.pi/n)
            for i in range(imax+1):
                if rd>rb:
                    r=rd+i*dr
                else:
                    r=rb+i*dr
                theta=math.sqrt((r*r)/(rb*rb)-1.)
                alpha=theta-math.atan(theta)
                xpt=r*math.sin(alpha-ang)
                ypt=r*math.cos(alpha-ang)
                xd=rd*math.sin(-ang)
                yd=rd*math.cos(-ang)
                if(i==0):
                    last_x = midx+xd
                    last_y = midy-yd
            self.create_line((lxd),(lyd),(midx+xd),(midy-yd),fill=color)
            for i in range(imax+1):
                if rd>rb:
                    r=rd+i*dr
                else:
                    r=rb+i*dr
                theta=math.sqrt((r*r)/(rb*rb)-1.)
                alpha=theta-math.atan(theta)
                xpt=r*math.sin(ang2-alpha)
                ypt=r*math.cos(ang2-alpha)
                xd=rd*math.sin(ang2)
                yd=rd*math.cos(ang2)
                if(i==0):
                    last_x = midx+xd
                    last_y = midy-yd
                self.create_line((midx+xpt),(midy-ypt),(last_x),(last_y),fill=color)   
                if(i==imax):
                    rfx=midx+xpt
                    rfy=midy-ypt
                last_x = midx+xpt
                last_y = midy-ypt
            self.create_line(lfx,lfy,rfx,rfy,fill=color)
canvas = doc['onegear2']
ctx = canvas.getContext("2d")
x = (canvas.width)/2
y = (canvas.height)/2
r = 0.8*(canvas.height/2)
# 齒數
n = 36
# 壓力角
pa = 20
Spur(ctx).Gear(x, y, r, n, pa, "blue")
</script>

#3.子模組建立與運用

<iframe width="560" height="315" src="https://www.youtube.com/embed/eAu4W6WtSns" frameborder="0" allowfullscreen></iframe>

#4.Solvespace 近端零組件繪圖

<iframe width="560" height="315" src="https://www.youtube.com/embed/0of4dnA_m6Q" frameborder="0" allowfullscreen></iframe>

<iframe src="./../w17/two link.html" width="800" height="600"></iframe>

#5.Solvespace 零件轉入 V-rep

<iframe width="560" height="315" src="https://www.youtube.com/embed/J4XD9bjRzkQ" frameborder="0" allowfullscreen></iframe>

#6.期末分組專題

<a href="https://40423119.github.io/2017springcd_hw/blog/40423119_qi-mo-fen-zu-zhuan-ti-_ag1.html">期末分組專題_AG1</a>

#7.上傳 Fossil SCM 倉儲

<iframe width="560" height="315" src="https://www.youtube.com/embed/iZb8CQ_iJRs" frameborder="0" allowfullscreen></iframe>
