Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Need definition for Translate  (Read 2473 times)

0 Members and 1 Guest are viewing this topic.

OldFangle

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Need definition for Translate
« on: January 19, 2015, 06:06:38 am »
Hi
I can't find the introductory definition for 'Translate' in the context of Transform.
I see many references to it, e.g.

          sf::Transform t;
          t.translate(10, 100);


But I'm not 'getting' it.  What does it do?  Does it add a value to a value, does it move something, is it needed for calculating other Transform functions such as rotate() or scale(), without which those functions could not work?  I started back at the main SFML page, opened every tutorial category until my search found the word, but even there, in the first mention of 'translate', I saw only a reference to it, not an actual explanation for it.

Thanks to whomever can bring me up to speed on this.
OF

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Need definition for Translate
« Reply #1 on: January 19, 2015, 07:31:58 am »
It is described in the API documentation: http://www.sfml-dev.org/documentation/2.2/classsf_1_1Transform.php
http://www.sfml-dev.org/documentation/2.2/classsf_1_1Transform.php#ab54f6c8070cc05e2afcb3145fbf4395a
Also, google translate (in the mathematical sense). That should get you started.
If you need more, just say so :-)
« Last Edit: January 19, 2015, 07:50:44 am by Laurent »

OldFangle

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Need definition for Translate
« Reply #2 on: January 19, 2015, 08:37:26 am »
Hi.  Thanks for writing.
Yes, this is one of the first things I found when I was looking for an explanation of what it is and what it does.
>>>
Transform& sf::Transform::translate(float x, float y)       

Combine the current transform with a translation.

This function returns a reference to *this, so that calls can be chained.
sf::Transform transform;
transform.translate(100, 200).rotate(45);

Parameters
    x   Offset to apply on X axis
    y   Offset to apply on Y axis

Returns
    Reference to *this

See also
    rotate, scale
<<<

So it's used when rotating and scaling, then.  If that's the explanation and there isn't any other, then thanks for pointing me back to this.  I guess the way to actually apply it will finally click for me when I've seen it used enough times that I can cross-reference the context(s) a little bit.

Thanks again
OF

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10862
    • View Profile
    • development blog
    • Email
AW: Need definition for Translate
« Reply #3 on: January 19, 2015, 08:43:04 am »
There are three basic transformations: translate, scale and rotate

Translate "moves" the object from position a to position b.
Scale enlarges or shrinks the objects dimensions.
Rotate well rotates the object for a certain angle.

All the transformations happen around the origin point.

These concepts are not specific to SFML, but are something from vector math and thus are explained on lots of websites including Wikipedia.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

OldFangle

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Need definition for Translate
« Reply #4 on: January 19, 2015, 08:52:35 am »
Thanks!

Yes, I tried 'Googling' it, using "C++ translate", I didn't recognise it as a Math feature.
The Wikipedia article at http://en.wikipedia.org/wiki/Translation_unit_%28programming%29  didn't lead to my sussing specifically that 'translate' means to move.  I saw scale(), rotate(), move(), mentioned elsewhere in the SFML documentation so I thought 'move' wasn't what translate() meant.

Anyway, thanks for the help!
OF

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10862
    • View Profile
    • development blog
    • Email
Re: Need definition for Translate
« Reply #5 on: January 19, 2015, 09:14:07 am »
scale(), rotate() and move() are the functions of the Transformable class. Granted if one wanted to stay "mathematical" one would had to pick translate() instead of move(), but since move() is better understood and shorter, it makes sense for convenience.

Just look up some 2D vector math, it will help you a lot with game programming anyways.
« Last Edit: January 19, 2015, 09:33:07 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

OldFangle

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Need definition for Translate
« Reply #6 on: January 19, 2015, 09:20:23 am »
It sure has!  I'm glad to see some of that old math, I remember wondering at the time how I'd ever get a chance to use it.  It looked like fun at the time but the classroom wasn't and I forgot most of it due to daily un-use.  Forty years later, here we all are again.
I've been keeping this SFML textbook central, and as I come across something on which I'm unclear I head out to get more information on it.  That 'translate' thing was a special snag.  Thanks for taking the time.

Cheers
OF