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.

Geek Culture / Game Maths Help.. (Specificly Co-Ordinates)

Author
Message
BENOJ
18
Years of Service
User Offline
Joined: 17th Mar 2006
Location: UK
Posted: 16th Mar 2007 23:26
Hi, im working on a Co-Ordinate System, and ive run into a problem, that is, my maths skills . I've Asked a few friends whom are doing 'Alevel maths' at my school, none of them knew, so im not sure if this is relatively complicated or, that they just havent had to learn it. Anyway i basicaly need to work out some co-rdinates in a circle (or sphere).
Myself being a person who poorly tries to explain problems, i thought i would avoid this by drawing you all a nice pretty picture of what i am trying to work out. I have uploaded it to this post so if anyone has the time i would be most gratefull if you could have a look through for me that would be great.
Thanks,
BEN

ps. The Green lines are supposed to be X and Y axis with the 0 intersection being at the very centre of the cube



Attachments

Login to view attachments
Venge
18
Years of Service
User Offline
Joined: 13th Sep 2006
Location: Iowa
Posted: 16th Mar 2007 23:42
And here's the jpg

I would guess use some kind of trigenometry, I'm not taking that til next year though

Soon to come: Corvette vs. the Enzo

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Mar 2007 23:43 Edited at: 17th Mar 2007 08:28
what's a .dib file?


[removed and noob slapped myself]

Not sure which coordinates you want to find. The center of the circle? Or the points at 1,2,3,4?

Venge
18
Years of Service
User Offline
Joined: 13th Sep 2006
Location: Iowa
Posted: 16th Mar 2007 23:44
lol, maybe it's friday the 17th in the UK

Soon to come: Corvette vs. the Enzo
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Mar 2007 23:45
time traveller! it's sorcery i tell ya!

BENOJ
18
Years of Service
User Offline
Joined: 17th Mar 2006
Location: UK
Posted: 17th Mar 2007 00:10 Edited at: 17th Mar 2007 00:11
Quote: "
Oh, and I noticed you just joined today. I find something odd about your join date though. You'll see what I mean with this picture of my computer's clock.
"


Hmmm... guys maby you should loo ka little closer '06 Tomorrow is my Aniversery yay didnt resalise

Quote: "what's a .dib file?"

sorry didnt realise, vista.. paint, i assumed it saved in .jpeg ... should have lokoed a bit harder .

yeah its definately Trigonometrical, but i only know how to use it in trianges... i assume that it would be used as millions of triangles forming a cirlce... I'm pretty good at learning maths and doing it ... jusrt dotn ask me to work stuff out. Im a doer nto an inventor

and yeah the orange coo-ordinates, where teh object intersects with the circle.



Crazy Ninja
19
Years of Service
User Offline
Joined: 27th Aug 2005
Location: Awesometon
Posted: 17th Mar 2007 04:23
@Phaelax - Lol!

Just wanted to say that. (retreats into a hole)

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Mar 2007 08:28 Edited at: 17th Mar 2007 08:29
ugh.... im such a noob.


Nothing really tricky to get those 4 points.

Assuming these contraints:
- the orange shape is a square of 4 equal sides
- straight up is zero degrees

theta = rotation of square

x1 = sin(theta+45)*radius
y1 = cos(theta+45)*radius
x2 = sin(theta+135)*radius
y2 = cos(theta+135)*radius
x3 = sin(theta+225)*radius
y3 = cos(theta+225)*radius
x4 = sin(theta+315)*radius
y4 = cos(theta+315)*radius


I might have the sin/cos switched around, can't remember.

PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 17th Mar 2007 10:34
Well... this is one idea I possibly had, I presume you know how to do trigonometry

Say we are trying to work out point 3.

We know the length of the corner of the square to the center of the circle is 1. This gives us a hyp length.

Now to work out the X coordinate all we need to do is:
0 - (1 x cos45)
and for the Y:
0 - (1 x sin45)


You then only need to find another point, point 1 for example to work out all the other points, or you could apply this method.


I can't say if this is 100% accurate but it should be ok...

The Innuendo's, 4 Piece Indie Rock Band
http://theinnuendos.tk:::http://myspace.com/theinnuendosrock
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Mar 2007 12:21 Edited at: 17th Mar 2007 12:22
Quote: "x1 = sin(theta+45)*radius
y1 = cos(theta+45)*radius
x2 = sin(theta+135)*radius
y2 = cos(theta+135)*radius
x3 = sin(theta+225)*radius
y3 = cos(theta+225)*radius
x4 = sin(theta+315)*radius
y4 = cos(theta+315)*radius"

(Don't forget to add your center values)

And to speed up your game a little([edit] sorry, this isn't for a game is it?), you can calculate only 2 points, and base the rest on them (CX and CY are the center of your square, radius is the distance from the center to each point):

`----------------------------
vx1 = cos(theta + 45)*radius
vy1 = sin(theta + 45)*radius

vx2 = cos(theta - 45)*radius
vy2 = sin(theta - 45)*radius

`-->
x1 = CX + vx1
y1 = CY + vy1

x2 = CX + vx2
y2 = CY + vy2

x3 = CX - vx1
y3 = CY - vy1

x4 = CX - vx2
y4 = CY - vy2
`----------------------------


And at last, how to calculate the radius with only a side given:
side = 2 * (sin(45)*radius)
<=> side/2 = (sqrt(2)/2)*radius
<=> radius = (side/2) / (sqrt(2)/2)
<=> radius = side / sqrt(2)
or also radius = sqrt(2)*side/2

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 17th Mar 2007 15:06
The side of the square doesn't go all the way to the edge... consequently the side of the square creates an arc and not a tangent to the circle, no?

The Innuendo's, 4 Piece Indie Rock Band
http://theinnuendos.tk:::http://myspace.com/theinnuendosrock
BENOJ
18
Years of Service
User Offline
Joined: 17th Mar 2006
Location: UK
Posted: 17th Mar 2007 17:02 Edited at: 17th Mar 2007 17:27
Hmm.. Tried those equations and it did a similar thing to what happened when i attempted it, basicaly instead of each vertex moving around, they move miles away and cause the box to get thinner and strechesd along one axis, meaning it look verry strange lol.

Sorry if i have confused anyone by my picture, that was suppolsed to be any shape rrly hopefully i can get this sorted, or else im gonna have to re-code the whole positioning system because there is a way i can make it work, by usign some of the opengl Matrix commands, but unfortunatley coz my system doesnt move the matrixs when i rotate the object it rotates around the original matrix.. which is very annoying

I did some research and i found there is an equation for rotation of anyshape, somethign like x= sin(theta) - cos(theta) etc... but i never got it to work unfortunaley (yes i did convert the radians to degrees incase ne one was wondering ) any mathmaticians know hwo i can get this to work?

( This is to rotaet a 3D shape along its Y axis btw );

Thanks ,
BEN



PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 17th Mar 2007 17:09
yrotate ?

The Innuendo's, 4 Piece Indie Rock Band
http://theinnuendos.tk:::http://myspace.com/theinnuendosrock
BENOJ
18
Years of Service
User Offline
Joined: 17th Mar 2006
Location: UK
Posted: 17th Mar 2007 17:14
this isnt a DBP project .. C++ with OpenGl sorry if you didnt realise.. tiold you i was bad at explaioning things

-BEN



BENOJ
18
Years of Service
User Offline
Joined: 17th Mar 2006
Location: UK
Posted: 17th Mar 2007 20:38
Ok i managed to fix it .
But in the most stupid possible way!!

Ok i just though .. screw it i'll just recode the whole thing! Mayaswell get it out the way.

So i did, then when i finished i recompiled and ... NO IT STILL DID THE SAME THING.

it really annoyed me !

then i spen the next hour or so going through the code with a fine comb, and i realised! I had 2 lines in the wrong order which was making the whole thing not work i was quite happy, but then i realised... it wasnt broken before

But on the upside, the new restructuring of the code means that it is a lot more efficient, coz before each function looked at each vertex individualy, this one hover just moves the whole matrix so doesnt use as much memory, or call tan cos etc.. functions .



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Mar 2007 21:58 Edited at: 17th Mar 2007 22:08
Here's DBP code to demonstrate finding the points with rotation.



BENOJ
18
Years of Service
User Offline
Joined: 17th Mar 2006
Location: UK
Posted: 17th Mar 2007 22:03
think you could compile it for me?
i can't compile ot so i cant see the output. I wiped my HDD and when i re-installed DBP i didnt have my serial lol and i dont have it in my email or n e thign .... so i cant compile any DBP anymore

anyone know where i can get that sorted



Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Mar 2007 22:09
here you go

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-18 09:28:02
Your offset time is: 2024-11-18 09:28:02