传说中的公式们
hello world !!
1.平面2d转2.5d坐标(伪坐标,还是2d)

A(_center)点为定点:
其他(左图坐标点(_positionX, _positionY))的旋转45度变换坐标,Lua实现:
function coordConverTo(self, _positionX, _positionY, _centerX, _centerY) local x, y local angleRotate = 45 forCenterX = _centerX * math.cos(math.rad(angleRotate)) - _centerY * math.sin(math.rad(angleRotate)) forCenterY = (_centerX * math.sin(math.rad(angleRotate)) + _centerY * math.cos(math.rad(angleRotate))) / 2 print( " here 1: %d, %d", _positionX, _positionY ) x = _positionX * math.cos(math.rad(angleRotate)) - _positionY * math.sin(math.rad(angleRotate)) + _centerX - forCenterX y = (_positionX * math.sin(math.rad(angleRotate)) + _positionY * math.cos(math.rad(angleRotate))) / 2 + _centerY - forCenterY print( " here 2: %d, %d", x, y ) return x, y end
也有一个比较简便的求x’,y’方法,就是按照2.5D是2D坐标系旋转45度,然后高度压缩一半来求
以原点(0,0)为定点旋转公式:
x’= x*cos45°-y*sin45° y’= (x*sin45°+y*cos45°) / 2
-----以上算法,待验证!!
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号