This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cross2=(x1,y1,x2,y2,x3,y3,x4,y4)-> | |
ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1) | |
eta = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1) | |
delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3) | |
ramda = ksi / delta | |
mu = eta / delta | |
if ramda >= 0 and ramda <= 1 and mu >= 0 and mu <= 1 | |
x = x1 + ramda * (x2 - x1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDistance:(p1x,p1y,p2x,p2y)-> | |
dx=p1x-p2x | |
dy=p1y-p2y | |
return Math.sqrt(dx*dx+dy*dy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onlaod=()-> | |
a1x=100 | |
a1y=100 | |
c1x=200 | |
c1y=200 | |
c2x=300 | |
c2y=200 | |
a2x=400 | |
a2y=100 | |
result=[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<$MTEntryTitle remove_html="1"$> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#2次ベジェの中間点の座標を求める | |
#a1はアンカーポイント1 | |
#c1はアンカーポイント1から出るコントロールポイント | |
#c2はアンカーポイント2から出るコントロールポイント | |
#a2はアンカーポイント2 | |
#tは分割する割合、0~1の範囲 | |
getQuadraticBezierPoint:(a1x,a1y,cx,cy,a2x,a2y,t)-> | |
tp = 1 - t | |
x = t*t*a2x + 2*t*tp*cx + tp*tp*a1x | |
y = t*t*a2y + 2*t*tp*cy + tp*tp*a1y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cross=(x1,y1,x2,y2,x3,y3,x4,y4)-> | |
ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1) | |
delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3) | |
ramda = ksi / delta | |
x = x1 + ramda * (x2 - x1) | |
y = y1 + ramda * (y2 - y1) | |
return [x,y] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MTSetVarBlock name="catList"><MTEntryCategories glue=" OR "><$MTCategoryLabel$></MTEntryCategories></MTSetVarBlock> | |
<MTSetVarBlock name="baseTitle"><$MTEntryTitle$></MTSetVarBlock> | |
<h2>関連記事</h2> | |
<ul> | |
<MTEntries lastn="6" categories="$catList"> | |
<MTSetVarBlock name="relatedTitle"><$MTEntryTitle$></MTSetVarBlock> | |
<MTIf name="relatedTitle" ne="$baseTitle"> | |
<li><a href="<$MTEntryLink$>"><$MTEntryTitle$></a></li> | |
</MTIf> | |
</MTEntries> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#座標(p1x,p2y)と座標(p2x,p2y)を結ぶ線分をt:1-tで分割した座標を求める | |
interpolate:(p1x,p1y,p2x,p2y,t)-> | |
return [ | |
p1x+(p2x-p1x)*t, | |
p1y+(p2y-p1y)*t | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#直線の座標A、直線の座標、円の中心点の座標、円の半径 | |
getPointsOfIntersectionWithLineAndCircle=(aX,aY,bX,bY,cX,cY,r)-> | |
a = bY - aY | |
b = aX - bX | |
c = -( a*aX + b*aY ) | |
l = Math.sqrt((bX-aX)*(bX-aX)+(bY-aY)*(bY-aY)) | |
eX = (bX - aX) / l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Config | |
_instance = null | |
constructor:()-> | |
throw new Error 'Cant create instance, use \'getInstance\'.' | |
@getInstance: () -> | |
_instance ?= new _PrivateClass() | |
class _PrivateClass | |
str:'some string !' |