·¹ÀÌ¾î ¿øÇüÀ¸·Î À̵¿Çϱâ go to ·¹À̾îÀ̵¿Çϱâ




·¹À̾ ¿øÇüÀ¸·Î À̵¿½Ã۱â À§Çؼ­´Â ƯÁ¤ ÁÂÇ¥¿¡¼­ ƯÁ¤ °¢µµ¸¦ left¿¡´Â Math.cos(°¢µµ) ¸¦ top¿¡´Â Math.sin(°¢µµ) °ªÀ» ´õÇØÁÖ°í ÀÌ °¢µµ°ªÀ» ¹Ù²Ù¾î ÁÖ¸é °¢µµ¿¡ ¸Â´Â ÁÂÇ¥°ªÀ» °»½ÅÇÕ´Ï´Ù. ¿©±â¼­ ÇÑ ÁÂÇ¥¸¦ ±âÁØÀ¸·Î ¿øÇüÀ¸·Î À̵¿½Ã۱â À§Çؼ­ Áß½ÉÁ¡À» Àâ¾Æ¾ß ÇÕ´Ï´Ù. Áß½ÉÁ¡Àº ·¹À̾¼­ left¿Í topÀÇ À̵¿Æø¿¡ À§Ä¡½Ãų °¢µµ¸¦ ÁöÁ¤ÇÕ´Ï´Ù. ±×¸®°í ÀÌ °¢µµ¸¦ ¹Ù²Ù¾î ÁÖ¸é ·¹À̾ ¹Ù²ï °¢µµ¸¸Å­ À̵¿ÇÕ´Ï´Ù.
<DIV ID="D1" STYLE="position:absolute; left:200; top:200; width:50;">
   <IMG SRC="../../../images/img1.gif" WIDTH=50 HEIGHT=50 BORDER=0>
</DIV>
À§¿¡ ¿òÁ÷À̰í ÀÖ´Â ·¹À̾îÀÔ´Ï´Ù.
function init() {
  if(n4) circleLayer = new circleMoveSet(document.D1, 180, 100, 100)
  else if(e4) circleLayer = new circleMoveSet(document.all.D1, 180, 100, 100)
  moveCircle(); 
}
bodyÀÇ onLoad="init()"·Î ·¹À̾ ¿øÇüÀ¸·Î À̵¿½Ãų Á¤º¸¸¦ circleLayer¿¡°Ô ÁöÁ¤À» ÇÕ´Ï´Ù. 180Àº Ãʱ⠰¢µµÀ̰í 100, 100Àº left¿Í topÀ¸·Î ¿òÁ÷ÀÏ À̵¿ÆøÀÇ Àý¹Ý°ªÀÔ´Ï´Ù.
function circleMoveSet(layer, angle, hol, ver) { 

  this.layer = layer
  this.moveAngle = angle
  this.moveHol = hol
  this.moveVer = ver

  if(n4) {
    this.centerX = layer.left - hol * Math.cos(angle*Math.PI/180)
    this.centerY = layer.top - ver * Math.sin(angle*Math.PI/180)
  }
  else if(e4) {
    this.centerX = layer.style.pixelLeft - hol * Math.cos(angle*Math.PI/180)
    this.centerY = layer.style.pixelTop - ver * Math.sin(angle*Math.PI/180)
  }
}
ÃʱⰢµµ¸¦ 180À¸·Î ÁöÁ¤À» Çß½À´Ï´Ù. ƯÁ¤ °¢µµ¿¡ µû¸¥ leftÀÇ °ªÀº Math.cos(°¢µµ*Math.PI/180) À¸·Î ¾Ë ¼ö ÀÖ½À´Ï´Ù. °¢µµ°¡ 180À̸é Math.cos(180*Math.PI/180)Àº -1À̰í Math.cos(90*Math.PI/180)Àº 0ÀÔ´Ï´Ù.

À§ÀÇ Ç¥´Â cosine ±×·¡ÇÁÀÔ´Ï´Ù. °¢µµ¿¡ ´Ù¸¥ leftÀÇ °ªÀÌ 1¿¡¼­ -1±îÁöÀÇ °ªÀ» °¡Áý´Ï´Ù. ¸¶Âù°¡Áö·Î Math.sin(°¢µµ*Math.PI/180)´Â °¢µµ¿¡ µû¸¥ topÀÇ °ªÀ» °¡Áý´Ï´Ù. sine ±×·¡ÇÁÀÔ´Ï´Ù.

Math.sin(180*Math.PI/180)Àº 0ÀÔ´Ï´Ù. ±×·¡¼­ this.centerXÀÇ °ªÀº 300À̰í this.centerX´Â 100ÀÔ´Ï´Ù. left°¡ 200, topÀÌ 100ÀÎ ÁÂÇ¥ÀÇ ·¹À̾ ÃʱⰢµµ 180¿¡¼­ ¿øÇüÀ¸·Î À̵¿ÇÒ Áß½ÉÀ§Ä¡´Â 300, 100ÀÔ´Ï´Ù. °¢µµ¸¦ 90À¸·Î ÁÖ¸é Áß½ÉÀ§Ä¡´Â 200, 0 ÀÌ µË´Ï´Ù.

óÀ½ ÁöÁ¤ÇÏ´Â ÃʱⰢµµ´Â À̵¿ÇÒ ·¹À̾îÀÇ Áß½ÉÁ¡À» Àâ´Âµ¥ »ç¿ëÇÕ´Ï´Ù. ·¹À̾ À̵¿ÇÏ´Â ¹æÇâÀº moveAngleÀÌ ¿ªÈ°À» ÇÕ´Ï´Ù. ÀÌ Áß½ÉÁ¡¿¡¼­ moveAngle¿¡ ÁöÁ¤µÈ °¢µµ¿¡¼­ moveAngle¿¡°Ô °¢µµ¸¦ ÁÙ¿©ÁÖ¸é Áß½ÉÁ¡À» ±âÁØÀ¸·Î moveAngle °¢µµ¿¡¼­ cosine°ú sine ±×·¡ÇÁÀÇ »¡°­»ö¿¡¼­ ¿ÞÂÊÀ¸·Î sin, cos °ªÀÌ µÇ°í ¹Ý´ë·Î ´Ã¿©ÁÖ¸é ¿À¸¥ÂÊÀ¸·ÎÀÇ °ªÀÌ ÁöÁ¤µË´Ï´Ù.

function moveCircle() {

  if(n4) {
    circleLayer.layer.left = circleLayer.centerX + circleLayer.moveHol * Math.cos(circleLayer.moveAngle*Math.PI/180)
    circleLayer.layer.top = circleLayer.centerY + circleLayer.moveVer * Math.sin(circleLayer.moveAngle*Math.PI/180)
  }
  else if(e4) {
    circleLayer.layer.style.pixelLeft = circleLayer.centerX + circleLayer.moveHol * Math.cos(circleLayer.moveAngle*Math.PI/180)
    circleLayer.layer.style.pixelTop = circleLayer.centerY + circleLayer.moveVer * Math.sin(circleLayer.moveAngle*Math.PI/180)
  }
  circleLayer.moveAngle += 2
  setTimeout("moveCircle()", 1)
}
°¢µµ¸¦ 2µµ¾¿ Áõ°¡½ÃÄѼ­ ¿øÇüÀ¸·Î ·¹À̾ À̵¿½Ãŵ´Ï´Ù. À§ÀÇ ±×·¡ÇÁ¿¡¼­ 180µµ¿¡¼­ °¢µµ¸¦ Áõ°¡½ÃŰ¸é »¡°£»öÀÇ ±×·¡ÇÁ °î¼±°ú °°ÀÌ left, topÀÇ °ªÀÌ º¯È­ÇÕ´Ï´Ù. 360 À̳ª -360 ÀÌ ³ÑÀ¸¸é 0ÀÌ µË´Ï´Ù. ¹«ÇÑ´ë·Î °¢µµ¸¦ ´ÃÀ̰ųª ÁÙ¿©µµ Ç×»ó 0¿¡¼­ 360 ±îÁöÀÇ °¢µµ °ªÀÌ µË´Ï´Ù.

circleLayer.moveAngle -= 2 ·Î °¢µµ¸¦ ÁÙ¿©ÁÖ¸é ·¹À̾îÀÇ À̵¿¹æÇâÀº ¹Ý´ë°¡ µË´Ï´Ù. ¿©±â¼­´Â ½Ã°è¹æÇâÀ¸·Î ·¹À̾ µ¹°Ô °¢µµ¸¦ Áõ°¡ ½ÃÄ×½À´Ï´Ù. ¹Ý½Ã°è¹æÇâÀ¸·Î µ¹°Ô ¸¸µé·Á¸é °¢µµ¸¦ ÁÙ¿©ÁÖ¸é µË´Ï´Ù.

À§ÀÇ Äڵ带 »ç¿ëÇÑ ·¹À̾î À§Ä¡¿¡ µû¸¥ °¢µµ´Â Áß½ÉÁÂÇ¥¿¡¼­ »çºÐ¸éÀ¸·Î ³ª´©¸é ½Ã°è¹æÇâÀ¸·ÎÀÇ °¢µµ°¡ µË´Ï´Ù.

·¹À̾ 90°ú 180 »çÀÌ¿¡ ÀÖ´Ù¸é circleLayer.moveAngle%360Àº 90°ú 180»çÀÌÀÇ °ªÀ» °¡Áö°í ÀÖ½À´Ï´Ù.


ÀÌ ÆäÀÌÁöÀÇ ¹æ¹ýÀº À̵¿½Ãų ·¹À̾ óÀ½ À§Ä¡ ½Ãų¶§ ÀÏÀÏÀÌ °è»êÀ» ÇÏ¿© ÁöÁ¤À» ÇØ¾ßÇϰí, ·¹À̾ ¿©·¯°³¶ó¸é ´õ º¹ÀâÇÑ °è»ê°ú ½ÃÇèÀ» ÇØºÁ¾ß ÇÕ´Ï´Ù. ±×¸®°í ¿øÇüÀ¸·Î À̵¿Çϰí ÀÖ´Â ·¹À̾ Á߽ɰªÀ» ¹Ù²Ù°Å³ª ¿øÇü À̵¿¹æÇâµî ´Ù¸¥ ÀÛ¾÷À» ÇÒ ¼ö ¾ø½À´Ï´Ù.

´ÙÀ½Àº óÀ½ ÁÂÇ¥°ªÀ» ½Å°æ¾²Áö ¾Ê°í ¿øÇüÀ¸·Î À̵¿½Ãų ·¹À̾ ¹èÄ¡ÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù.

¿øÇüÀ̵¿ ·¹À̾î ÀÚµ¿¹èÄ¡Çϱâ




TOP