View unanswered posts | View active topics It is currently Wed Aug 12, 2020 5:51 am

Reply to topic  [ 2 posts ] 
 Rotation matrix will magnify your manufacturer logos 
Author Message
User avatar

Joined: Fri Jan 01, 2010 4:02 pm
Posts: 525
Post Rotation matrix will magnify your manufacturer logos
Hi there,

I've recently came across Herbal's Manufacturers logos and after my first thought that was "it's a great thing that will fit into my Packs" an idea came to my mind.

You know, it's rather time-consuming and kinda irritating process to make a decent logo situated exactly in front of the camera eye (in the "standing" position) manually. Actually, the easiest way to make logo is to make it flat, with Y coordinate set to zero (roughly). That's just how, for example, already mentioned Herbal's logos were made, then in the main menu they look flat.

Despite their flatness, they surely make a very worthy addon. However, with use of some basic linear algebra, every logo, including these you might want to create in the future on your own, might look even better. :misch:

In order to raise a flat logo to make it stand as it should, you need to find a suitable linear map. In this case, we need to (some spatial imagination required :rofl:) rotate the logo by 45 degrees in the Y=0 plane (names of axis might be confusing, Car Editor doesn't use the standard basis of the 3-dimensional linear space, so directions are different. Briefly speaking, X - width, Y - height, Z - length) and then rotate it again by 45 degrees around x=-z line. Yay, now our logo lies on the plane defined by equation: x+y+z=0 (with normal vector (1, 1, 1) pointing at the camera eye).

Now it's time to find a matrix of this map. I did it already and it looks like this:
      | 0.7    0.5    0.5  |
  M = |   0    0.7   -0.7  |   (where 0.7 comes from sqrt(2)/2 = 0.707, roughly)
      | -0.7   0.5    0.5  |

It's called rotation matrix. What can we do with this? Let v=(x, y, z) be vector representing a vertex, with its XYZ coordinates. And every kid knows that if we multiply M*v we will get an output vector representing our output vertex. For example:
      |  0.3 |          | 0.7    0.5    0.5  | |  0.3 |    |  0.4271  |
  v = | 0.03 |    M*v = |   0    0.7   -0.7  | | 0.03 | =  | -0.2616  |
      |  0.4 |          | -0.7   0.5    0.5  | |  0.4 |    |  0.0029  |

So the vector u=(0.43, -0.26, 0) is the image of v in our linear map (the rotation). Follow this procedure with all of your remaining vertices and you'll get a beautiful, standing logo ;)

And the final comparison:
logos.png [ 3.34 KiB | Viewed 11492 times ]

Actually, leaving 0.707 instead of sqrt(2)/2 was not very wise either, 0.7 will do the work with the same effect, so you know what to do. ;)

Last edited by Lorenzo on Sat Jan 05, 2019 5:43 pm, edited 6 times in total.

Sun Aug 23, 2015 10:50 pm
Profile E-mail
User avatar

GeneRally Carmaster

Joined: Sat Dec 26, 2009 7:52 pm
Posts: 1819
Location: Budapest, Hungary
Post Re: Rotation matrix will magnify your manufacturer logos
That is a great find, Lorenzo! I wish I could have find that out by myself (since I've learned some vector calculus, after all), but it's still a great feeling to be a base for that kind of ideas. ^^

EDIT: 0.7 should be enough, you don't need to be that precise with square rooting.
RE-EDIT: Now do I see, that you've seen that too. ^^

Founder and ex-administrator of GeneRally International Forum
Räbinä Awards: Competition organizer 2012, Carmaker 2014
My racing career, my tracks, and my cars

Sun Aug 23, 2015 11:01 pm
Profile E-mail WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.