Jump to content
  • Advertisement
Sign in to follow this  
Leathrewulfe

Need math help

This topic is 3733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to create/find a general formula for finding point P1 when you know point P0 and the lengths and angles of the parallelograms involved. Here is an example illustration: http://www.lycanth.com/leathrewulfe/example.png Thanks

Share this post


Link to post
Share on other sites
Advertisement
I don t think it is possible to solve this, because there is no relation between the small and the large parallelogram.
Looking at you picture the large parallelogram could be anywhere?
Is there some constraint that the small parallelogram's edge's center touches the large one's edge center?

With the information you did provide I see no way to find P1
What you need to know is some kind of information to calculate the translation of the second parallelogram.

P.S.: this sounds a lot like homework

Share this post


Link to post
Share on other sites
Yes, they would be touching with the smaller adjoining the larger at midpoint on the one side. The parallelograms actually represent rooms as part of a level layout.

Actually, I decided to create a "level" editor as a workaround to me computing the next room point manually. This way I can drag and drop my "rooms" and have the positions already computed by the mouse position plus an offset. I really should have done this right from the beginning anyway.

Thanks, though.

As far as homework...I haven't had homework in over 12 years ;)

Share this post


Link to post
Share on other sites
There are two ways how to do this.

1. find center of first, then find center of second, and recompute all points of second paralleogram.

2. If your picture is correct, find center of neighbouring sides, and extend vector into proper location.

Share this post


Link to post
Share on other sites
We're going to create three vectors and add them. We'll call them v0, v1, v2
I'm using 30 degrees as the angle (half of 60), but I'm showing this in degrees. When you code, you'll have to convert that to radians.

v0) Find the vector going from p0 to the big square (roughly the northeast direction)
v0.x = 200 * cos(30)
v0.y = 200 * sin(30)

v1) The vector going from P0 half way down the width of the smaller rectangle (southeast direction)
v1.x = 50 * cos(30)
v1.y = 50 * sin(-30)

v2) The vector going from P1 half way down the length of the bigger rectangle (southeast direction)
v2.x = 250 * cos(30)
v2.y = 250 * sin(-30)

Then just add the vectors...
vFinal.x = v0.x + v1.x + v2.x
vFinal.y = v0.y + v1.y + v2.y

Share this post


Link to post
Share on other sites
I think v2 should be subtracted, shouldn't it? v0+v1 gives the midpoint of that one side, then subtraction of half the length vector of the larger parallelogram lines up the midpoints.

Another way to see the problem: all of the x components are positive without subtraction, which means v0.x + v1.x < v0.x + v1.x + v2.x, but that puts the x coordinate of vFinal (P1) past the x coordinate of the midpoint v0+v1. From looking at the picture, that shouldn't be right.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!