Rotation matrix will magnify your manufacturer logos

Improve your skills by learning the tricks of experienced members!
Post Reply
User avatar
Lorenzo
Posts: 534
Joined: Fri Jan 01, 2010 4:02 pm

Rotation matrix will magnify your manufacturer logos

Post by Lorenzo »

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:

Code: Select all

      | 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:

Code: Select all

      |  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
logos.png (3.34 KiB) Viewed 13300 times
EDIT:
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.
User avatar
Herbal
GeneRally Carmaster
Posts: 1831
Joined: Sat Dec 26, 2009 7:52 pm
Location: Budapest, Hungary
Contact:

Re: Rotation matrix will magnify your manufacturer logos

Post by Herbal »

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
Post Reply