View Single Post
03-01-16, 10:54 AM   #50
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by zork View Post
Hmmm. When working with textures that use an aspect of 1 (square), is the following condensed Transform function correct?

Lua Code:
  1. local mcos, msin = math.cos, math.sin
  2. local function Transform(texture, angle)
  3.   local c,s = mcos(angle), msin(angle)
  4.   local ULx, ULy = 0.5-c+s, 0.5-c-s
  5.   local LLx, LLy = 0.5-c, 0.5-s
  6.   local URx, URy = 0.5+s, 0.5-c
  7.   local LRx, LRy = 0.5, 0.5  
  8.   texture:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy)
  9. end
Yeah, if you're only manipulating square textures it looks like that does the same thing as calling Transform(-0.5, -0.5, angle, 1) with the function I wrote.

If you'd rather work with degrees instead of radians, I believe the blizzard functions sin and cos are degree-based instead of the radian-based math.sin and math.cos, so you don't even have to convert between them if you use those instead.
  Reply With Quote