2DÊ¿Ì̤DzÃË¡ÄêÍý¤ò»È¤¦

»°³Ñ´Ø¿ô¤Î²ÃË¡ÄêÍý¤ò¤´Â¸¤¸¤Ç¤·¤ç¤¦¤«¡©

¹â¹»¤Î¿ô³Ø¤Ç½¬¤¦¤ä¤Ä¤Ç¤¹¡£
¸¡º÷¤·¤Æ¤â¡¢¼ÂºÝ¤Î¥×¥í¥°¥é¥à¤Ç¤Î»È¤¤Êý¤äÍ­¸úÅÀ¤¬¸«¤Ä¤«¤ë¤³¤È¤Ï³§Ìµ¤Ë¶á¤¤¡£
¤Þ¤ë¤Ç¡¢Æþ³Ø»î¸³¤Î¤¿¤á¤À¤±¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£

¿Þ·Á¤Î²óž¤¬Ï¢Â³¤¹¤ë¥±¡¼¥¹¤Ç¤Ï¡¢³ÑÅÙ¤òÊÝ»ý¤¹¤ë¥×¥í¥°¥é¥à¤¬¤Û¤È¤ó¤É¤Ç¤¹¡£
¤·¤«¤·¡¢¤³¤¦¤¤¤Ã¤¿¥±¡¼¥¹¤Ç¤Ï¡¢sin, cos ÃͤòÊݸ¤·¤Æ¤ª¤¤¤¿Êý¤¬¡¢
if ʸ¤¬¾¯¤Ê¤¯¤Ê¤ê¡¢ÉÔ¶ñ¹ç¤¬¾¯¤Ê¤¯¤Ê¤Ã¤¿¤ê¤·¤Þ¤¹¡£

-------

¤¢¤ë¶ë·ÁABCD¤¬¤¢¤Ã¤¿¤È¤·¤Æ¡¢AÅÀ¤ò¸ÇÄê¤Ë¤·¤ÆCÅÀ¤òÆ°¤«¤¹¡£
ÊѲ½¸å¤Î¶ë·ÁAB¡ÇC¡ÇD¡Ç ¤òµá¤á¤ë¡£
⤷¡¢¶ë·Á¤Î½Ä²£Èæ¡ÊAspectÈæ¡Ë¤ÏÊѤ¨¤Ê¤¤¤â¤Î¤È¤¹¤ë¡£



¶ë·Á¤Î³ÈÂçΨ(¦Á)¤Ï¡¢¼¡¼°¤Çµá¤Þ¤ë¡£

¸µ¤Î¶ë·Á¤ÎÉý¤È¹â¤µ¤ò¤½¤ì¤¾¤ì¡¢w,h¤È¤·¡¢ÊѲ½¸å¤ÎÉý¤È¹â¤µ¤òw¡Ç,h¡Ç ¤È¤¹¤ë¡£
¤Þ¤¿¡¢²óž³Ñ¤ò¦È ¤È¤¹¤ë¡£
A,C¡Ç ¤Ï´ûÃΤǤ¢¤ë¤Î¤Ç¡¢B¡Ç ¤«D¡Ç ¤Î¤¤¤º¤ì¤«¤¬¤ï¤«¤ì¤ÐÎɤ¤¡£

´ö¤Ä¤«¤ÎÊýË¡¤¬¹Í¤¨¤é¤ì¤ë¤¬¡¢
ñ½ã¤Ê¤Î¤Ï¡¢³ÈÂçΨ(¦Á)¤È²óž³Ñ(¦È) ¤òµá¤á¤Æ¡¢¼¡¤Î¹ÔÎó¤ËÂåÆþ¤·¤Æ·×»»¤¹¤ëÊýË¡¤À¤í¤¦¡£

¤³¤ÎÊýË¡¤Î·çÅÀ¤Ï¡¢¦È ¤òµá¤á¤ë¤ÈÆÃÄê¤Î¾Ý¸Â¤Ë¤ª¤¤¤Æ¡¢Éä¹æ¤ÎÁàºî¤¬É¬Íפˤʤ뤳¤È¤À¤í¤¦¡£
Î㤨¤Ðatan¤Ç¤Ï¡¢(-¦Ð/2 ¡å ¦È ¡å ¦Ð/2)¤ÎÈϰϤǤ·¤«¡¢Åú¤¨¤¬µá¤Þ¤é¤º¡¢
acos¤Ç¤Ï(0 ¡å ¦È ¡å ¦Ð)¤ÎÈϰϤǤ·¤«µá¤Þ¤é¤Ê¤¤¡£
C¡Ç ¤òAÅÀ¤òÃæ¿´¤Ë²óž¤µ¤»¤ë¤È¤ï¤«¤ê¤ä¤¹¤¤¡£
¤³¤ÎÊýË¡¤Ï°Õ³°¤È´Ö°ã¤¤¤òÈȤ·¤ä¤¹¤¯¡¢¥Æ¥¹¥È¥±¡¼¥¹¤âÁý¤¨¤ë¤Î¤Ç¡¢ÁªÂò¤¹¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£

A,C,C¡Ç ¤ÎºÂɸ¤¬¤ï¤«¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢
¥Ù¥¯¥È¥ëAC¡¢AC¡Ç ¤ÎÆâÀѤȳ°ÀѤ«¤écos¦È,sin¦È ¤ò»»½Ð¤¹¤ë¡£

ÆâÀѤθø¼°


³°ÀѤθø¼°


º£²ó¤Î¥±¡¼¥¹¤ËÅö¤Æ¤Ï¤á¡¢cos,sin¤ò²ò¤¯¤È¡¢


HTML5¤Îcanvas¥¯¥é¥¹¤Ç¤Ï¡¢Context.transform¤Ç¹ÔÎó±é»»¤¬²Äǽ¤Ê¤Î¤Ç
¹ÔÎ󼰤Υѥé¥á¥¿(cos,sin,-sin,cos)¤ò»ØÄꤹ¤ì¤ÐÎɤ¤¡£

°ìÅٲ󞤵¤»¤Æ¡¢¸å¤«¤é¹¹¤Ë²óž¤òÄɲ乤ë¾ì¹ç¤ò¹Í¤¨¤ë¡£
¿Þ¤Ç¤Ï¡¢C¡Ç ¤«¤éC'¡Ç ¤ËÀ©¸æÅÀ¤¬°ÜÆ°¤·¤¿¤È¤¹¤ë¡£


¤Þ¤ºÁ°½Ð¤ÎÊýË¡¤Ç¡¢¥Ù¥¯¥È¥ëAC¡Ç¡¢AC'¡Ç ¤ÎÆâÀѤȳ°ÀѤ«¤écos(¦Å),sin(¦Å)¤ò»»½Ð¤¹¤ë¡£

´û¤Ë¦È ²óž¤·¤Æ¤¤¤Æ¡¢¹¹¤Ë¦Å ¤Î²óž¤¬²Ã¤ï¤ë¤È¤¹¤ë¤È¡¢²ÃË¡ÄêÍý¤Ë¤è¤ê


³ÈÂçΨ¤âƱÍͤˡ¢´û¤Ë³ÈÂçΨ¦Â ¤Ç¤¢¤ê¡¢
¤³¤ì¤Ë³ÈÂçΨ¦Á ¤¬²Ã¤ï¤ë¤È¤¹¤ì¤Ð¡¢¦Â£ø¦Á ¤¬¹çÀ®³ÈÂçΨ¤Ë¤Ê¤ë¡£


¹¹¤ËȯŸ¤µ¤»¤Æ¡¢³ÈÂç½Ì¾®²óž¤¬ÃdzŪ¤ËϢ³ȯÀ¸¤¹¤ë¥±¡¼¥¹¤ò¹Í¤¨¤Æ¤ß¤Þ¤¹¡£



¥µ¥ó¥×¥ë¤ò¼Â¹Ô¤¹¤ë¤È¤ï¤«¤ê¤ä¤¹¤¤¡£

Áàºî¤È¤·¤Æ¤Ï¡¢
AÅÀ¤òCanvasÃæ±ûÅÀ¤È¤·¤Æ¡¢¥¯¥ê¥Ã¥¯ÅÀ¤òP¤È¤¹¤ë¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­¡¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

¤½¤Î¸å¡¢¥¹¥ï¥¤¥×Áàºî¤ÇP¡Ç ¤Þ¤Ç°ÜÆ°¤·¡¢¤³¤³¤Ç»Ø¤òÎ¥¤¹¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­¢¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

ºÆ¤Ó¡¢QÅÀ¤Ç¥¯¥ê¥Ã¥¯¤ò¹Ô¤¦¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­¢¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

¥¹¥ï¥¤¥×¤ÇQ¡Ç ¤Þ¤Ç°ÜÆ°¤·»Ø¤òÎ¥¤¹¡£
¡¡¡¡¡¡¡¡¤³¤Î»þ²èÌ̤ˤϡ¢­£¤Î¶ë·Á¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¡£

¼Â¸½ÊýË¡¤Ï¤¤¤í¤¤¤í¤¢¤ë¤¬¡¢
¥¹¥ï¥¤¥×OFF»þ¤Ë¡¢¤½¤Î»þÅÀ¤Î³ÈÂçΨ(¦Âx¦Á)¡¦²óž¾õÂÖ(sin(¦È+¦Å),cos(¦È+¦Å))¤òÊݸ¤·¤Æ¤ª¤­¡¢
¥¯¥ê¥Ã¥¯»þ¤Ë¡¢¦Â¡á¦Âx¦Á, sin(¦È)¡ásin(¦È+¦Å), cos(¦È)¡ácos(¦È+¦Å)
¤È¤·¤ÆºÆ³«»Ï¤¹¤ì¤ÐÎɤ¤¡£

Javascript¤Ç¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
<!DOCTYPE html>
<html>
<!-- 
// (c)Hundredsoft Corporation. 2013 All right reserved.
//
//	UTF-8¤ÇÊݸ¤·¤Æ²¼¤µ¤¤
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>³ÈÂç½Ì¾®²óž</title>

<script type="text/javascript">
new function() {
var m_img = new Image();
var m_ctx = null;
var m_O = null;
var m_baseX = 0;
var m_baseY = 0;
var m_cos = 1;
var m_sin = 0;
var m_prop = 1;
var m_Lcos = 1;
var m_Lsin = 0;
var m_Lprop = 1;

var mmove = function(x, y){
	// ClickºÂɸ-Ãæ¿´ ¥Ù¥¯¥È¥ë
	var vx0 = m_baseX - m_O.x;
	var vy0 = m_baseY - m_O.y;
	var r0 = Math.sqrt(vx0*vx0 + vy0*vy0);

	// ¥¹¥ï¥¤¥×ºÂɸ-Ãæ¿´ ¥Ù¥¯¥È¥ë
	var vx1 = x - m_O.x;
	var vy1 = y - m_O.y;
	var r1 = Math.sqrt(vx1*vx1 + vy1*vy1);

	var cos = (vx0*vx1 + vy0*vy1) / (r0*r1); // ÆâÀѤ«¤é
	var sin = (vx0*vy1 - vy0*vx1) / (r0*r1); // ³°ÀѤ«¤é
	var prop = r1 / r0;
	draw(prop, cos, sin);
};
var draw = function(prop, cos, sin){
	m_Lcos = m_cos*cos - m_sin*sin; // ²ÃË¡ÄêÍý(cos)
	m_Lsin = m_sin*cos + m_cos*sin; // ²ÃË¡ÄêÍý(sin)
	m_Lprop = m_prop * prop;     // ³ÈÂçΨ¤Î²ÃË¡¤Ï¾è¤¸¤ë¤À¤±
	m_ctx.clearRect(0, 0, m_O.x*2, m_O.y*2);
	m_ctx.save();

	 // ¹ÔÎó·×»»
	m_ctx.transform(
		m_Lcos*m_Lprop,  m_Lsin*m_Lprop,
		-m_Lsin*m_Lprop, m_Lcos*m_Lprop,  m_O.x, m_O.y);

	// Àè¤Ë²èÁüÃæ¿´¤ò¸¶ÅÀ¤Ë°ÜÆ°(ŬÍѽç¤ËÃí°Õ)
	m_ctx.transform(1, 0, 0, 1, -m_img.width/2, -m_img.height/2);

	m_ctx.drawImage(m_img, 0, 0);
	m_ctx.restore();
};

test1 = {
init: function(){
	var mouseDown = false;
	var canvas = document.getElementById('c');

	canvas.addEventListener('touchstart',
		function(e) {
			e.preventDefault();
			mouseDown = true;
			var n = e.touches.length;
			var rect=e.target.getBoundingClientRect();
			m_baseX = e.touches[n-1].pageX-rect.left;
			m_baseY = e.touches[n-1].pageY-rect.top;
			m_cos = m_Lcos;
			m_sin = m_Lsin;
			m_prop = m_Lprop;
		}, false);

	canvas.addEventListener('mousedown',
		function(e) {
			e.preventDefault();
			mouseDown = true;
			var rect=e.target.getBoundingClientRect();
			m_baseX = e.clientX-rect.left;
			m_baseY = e.clientY-rect.top;
			m_cos = m_Lcos;
			m_sin = m_Lsin;
			m_prop = m_Lprop;
		}, false);

	canvas.addEventListener('touchend',
		function(e) {mouseDown = false;}, false);

	canvas.addEventListener('mouseup',
		function(e) {mouseDown = false;}, false);

	canvas.addEventListener('touchmove',
		function (e) {
			e.preventDefault();
			var rect = e.target.getBoundingClientRect();
			if (mouseDown) {
				var n = e.touches.length;
				mmove(e.touches[n-1].pageX-rect.left,
					e.touches[n-1].pageY-rect.top);
			}
		}, false);

	canvas.addEventListener('mousemove',
		function (e) {
			e.preventDefault();
			var rect = e.target.getBoundingClientRect();
			if (mouseDown) {
				mmove(e.clientX-rect.left, e.clientY-rect.top);
			}
		}, false);

	m_img.onload = (function(){
		m_O = {x: canvas.width/2, y: canvas.height/2};
		m_ctx = canvas.getContext("2d");
		draw(1, 1 ,0);
	});
	m_img.width = 260;
	m_img.height = 390;
	m_img.src = "test.jpg";
}
}
};
</script>
</head>
<body onload="test1.init()">
<canvas id="c" width="640" height="640" style="background-color:#e0e0e0;">
</canvas>
</body>
</html>


°Õ³°¤ÈÌÌÅݤʽèÍý¤Ç¤¹¤¬¡¢¥³¡¼¥É¤ÎÄ̤ꡢ±é»»½èÍý¤Çifʸ¤Ï°ì¤Ä¤â¤¢¤ê¤Þ¤»¤ó¡£
¤³¤ÎÊýË¡¤ÎÍøÅÀ¤Ï¡¢¥á¥ó¥ÐÊÑ¿ô¤Î»ÈÍѤ¬¾¯¤Ê¤¤»ö¤È¡¢¦È ¤ò·×»»¤·¤Ê¤¤¡Ê»°³Ñ´Ø¿ô¤Î¸ø¼°¤Ï»È¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢ ´Ø¿ô¤È¤·¤Æ¤Îsin¤äcos ¤Ï»È¤Ã¤Æ¤¤¤Ê¤¤¡£»È¤Ã¤Æ¤¤¤ë¤Î¤Ï²Ã¸º¾è½ü¤È¥ë¡¼¥È¤Î¤ß¡£¡Ë¤³¤È¤Ç¡¢if ʸ¤ò¾Ê¤±¤ë»ö¤¬µó¤²¤é¤ì¤Þ¤¹¡£


¼Â¹Ô¥µ¥ó¥×¥ë¤Ï¤³¤Á¤é


IE9°Ê¹ß/Chrome/Safari/FF/Android¤Ç¡¢³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£




Tags: ¥×¥í¥°¥é¥à¥á¥â
author : HUNDREDSOFT | - | -