Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / a little math question

Author
Message
haliop_New
User Banned
Posted: 15th Jul 2015 23:11
what if i want to create a plane any size will do

lets say 1.00,1.00 in size
i want to rotate it so the top right and bottom right vertice will be lets say 1.25 , how will i rotate at at the right amount ?


thank you for your time.
haliop
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 16th Jul 2015 00:07
Your question makes no sense.
Rotating a plane will not change its size.

If you mean (as I presume you do) relative size on screen. Then you have a lot more to consider than just rotating the plane.
Are you rotating the plane around local coordinates? World coordinates? Some other coordinate system?
Where is the planes origin of rotation?
What if the camera moves?
What is the cameras FOV/aspect ratio?

Perhaps you should instead consider what it is you are trying to achieve and then see if there is a better way to do it.

AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Jul 2015 01:28
i think u need an angle for the rotation.
if u imagine this plane is inside a cylinder u can work with ATanFull
u have a from and to coordinate and the middle point.
with it you can get the delta angle.

1.25 is not a position you have x,y in 2d or x,y,z in 3d

AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 16th Jul 2015 14:16 Edited at: 16th Jul 2015 14:19
I've interpreted the question to mean this:



Unfortunately I don't have to time to look at this right now but if this correct then I can look at it later or someone else can have a go.

Although the question does say "top right and bottom right vertice" but what I've done is top left and bottom right so I might have misunderstood.

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Jul 2015 14:31 Edited at: 16th Jul 2015 14:38
and that i mean


AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Attachments

Login to view attachments
Uncle Martin
18
Years of Service
User Offline
Joined: 9th Jul 2006
Location: Tampa, Florida, USA
Posted: 18th Jul 2015 13:11 Edited at: 20th Jul 2015 07:02
If I understand the question, let's see if we can illustrate a generic solution that might be applicable to various situations.

Given the rectangular coordinates of a point rotated about an origin, what change in angle of rotation is needed/or allowed for a given constraint in the rectangular height coordinate?

x1 & y1 are the coordinates of starting point
y2 is the given height constraint for the rotated ending point
x2 & x3 are 2 possible x values for given y2 height constraint

a1 is the starting angle of rotation for point (x1, y1)
a2 & a3 are the 2 possible angles to give desired y2

Plan of attack: Use Pythagorean theorem & trigonometry

The length of the radius being rotated does not change, so per Pythagoras we can say:
x1^2 + y1^2 = x2^2 + y2^2 or x2 = sqrt(x1^2 + y1^2 - y2^2)
This gives us the new x2 value for the new desired y2 constraint.
Using trigonometric arctangent, we can determine the old angle of the x1,y1 vector & the new angle of the x2,y2 vector. We subtract the 2 angles to get the required rotation.

Of course there are complications..due to the situation & indicated by the square root function, for a given y2 there are 2 solutions or maybe none. So code must be added to check that the argument passed to sqrt is not negative & if not, then the sqrt result can also be negated to get a negative version. The following code demonstrates all of this & draws a picture similar to the one previously provided. Note that in a full implementation, checks must be added for the other corners, etc.

The A/D keys decrease/increase the height of the y2 constraint. The F/H keys decrease/increase the width of the object (i.e. x1)

Drawing the rotated object/sprite is left as an exercise for the reader.

Enjoy.



Code every line like it might be your last...
Someday it will be.
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Jul 2015 19:12 Edited at: 20th Jul 2015 19:13
That's pretty cool but it'd be nice to know if we understood the question correctly.

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB

Login to post a reply

Server time is: 2024-11-25 21:21:41
Your offset time is: 2024-11-25 21:21:41