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

Author Topic: Get coordinates on a rotated object?  (Read 5552 times)

0 Members and 1 Guest are viewing this topic.

cpl

  • Newbie
  • *
  • Posts: 19
    • View Profile
Get coordinates on a rotated object?
« on: September 03, 2008, 09:00:28 am »
I have an rectangle which can be rotated. I need to know how to get the top-right coordinates of the rectangle after rotation. This seems to be a very simple problem really but I suck at math  :oops:

Thanks!
________
Ford Customline specifications

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Re: Get coordinates on a rotated object?
« Reply #1 on: September 03, 2008, 11:10:29 am »
Quote from: "cpl"
I have an rectangle which can be rotated. I need to know how to get the top-right coordinates of the rectangle after rotation. This seems to be a very simple problem really but I suck at math  :oops:

Thanks!


Make a right triangle with the tilted rectangle and use Pythagoras's Theorem.

cpl

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Get coordinates on a rotated object?
« Reply #2 on: September 03, 2008, 07:17:43 pm »
Quote from: "quasius"
Make a right triangle with the tilted rectangle and use Pythagoras's Theorem.


I'm sorry, I don't really sure how you mean.
________
marijuana hemp

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Re: Get coordinates on a rotated object?
« Reply #3 on: September 04, 2008, 12:33:18 am »
Quote from: "cpl"
Quote from: "quasius"
Make a right triangle with the tilted rectangle and use Pythagoras's Theorem.


I'm sorry, I don't really sure how you mean.


Do you know how to use the Pythagorean theorem?  If not, google it and see if that helps.

cpl

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Get coordinates on a rotated object?
« Reply #4 on: September 04, 2008, 09:35:27 am »
Quote from: "quasius"
Do you know how to use the Pythagorean theorem?  If not, google it and see if that helps.


Yeah, I think I know how to use the Pythagorean theorem, if you mean this:  

A*A + B*B = C*C

However I'm still confused how this would help me, how can I get the coordinates from this?

(I'm sorry if I don't understand but as i said i really suck at math)
________
easy vape

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Get coordinates on a rotated object?
« Reply #5 on: September 04, 2008, 04:50:29 pm »
Most of these problems can be solved with the Pythagorean theorem and simple sin/cos/tan.  This is no exception (If I understand your question correctly, you can actually do this problem without PT explicitly).  You need to make a right triangle using one of the tilted sides of your rotated rectangle as the hypotenuse and then solve that triangle.
In SFML, sprites rotate around the upper-left pixel (also it's position) by default.  So use that as the known point and make with an adjacent side to make a solvable triangle which will also give you the x and y offsets from the known rotation point.  Then you can use the symmetry of the rectangle to solve for any side you care about.
If you still can't get it, post what you've tried.  Maybe an MSPaint drawing of how you're trying to solve this problem.  (You'll learn a lot more by fighting through these problems instead of just c+p'ing code if I were to just post the solution.)
I'm going to visit a religious community in a couple of hours and will be there until Monday afternoon, but I might be able to pop in at some point to answer questions.  If not, hopefully someone else can pick it up and help you figure this out.

cpl

  • Newbie
  • *
  • Posts: 19
    • View Profile
Get coordinates on a rotated object?
« Reply #6 on: September 06, 2008, 11:54:25 am »
Quote from: "quasius"
Most of these problems can be solved with the Pythagorean theorem and simple sin/cos/tan.  This is no exception (If I understand your question correctly, you can actually do this problem without PT explicitly).  You need to make a right triangle using one of the tilted sides of your rotated rectangle as the hypotenuse and then solve that triangle.
In SFML, sprites rotate around the upper-left pixel (also it's position) by default.  So use that as the known point and make with an adjacent side to make a solvable triangle which will also give you the x and y offsets from the known rotation point.  Then you can use the symmetry of the rectangle to solve for any side you care about.
If you still can't get it, post what you've tried.  Maybe an MSPaint drawing of how you're trying to solve this problem.  (You'll learn a lot more by fighting through these problems instead of just c+p'ing code if I were to just post the solution.)
I'm going to visit a religious community in a couple of hours and will be there until Monday afternoon, but I might be able to pop in at some point to answer questions.  If not, hopefully someone else can pick it up and help you figure this out.


I don't have access to my computer for a few days so I'm not able to test what you suggested. I'll post here when I do when I have tried it out.
________
ecig forum

 

anything