|
||||||
| Programming Theory Discuss programming theory, algorithm efficiency, logic, and other any other category where math and computer science overlap. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
At the very beginning I must warn you, that explaining the problem will be hard to me.
Now, that you've been warned I'll start with quick explanation: When position is relative to angle and angle is relative to position, how can I find the "perfect point"? Now to have an example. I have two points: A(Xa,Ya) and B(Xb,Yb), I also have angle between them which is stored in DIR. Point A - Static, moves with mouse move Point B - Relative to Angle between two points DIR - Relative to position of point B So in one step I want to calculate the perfect position of point B, so it won't have to reassign, without using loops with one, relatively short algorithm. And now, because it might not be sufficent, I'll give you a real-life example: I have a platformer I'm working on. There is a player, who is made out of 4 parts: Body with head, arm, and two legs. The last two are not important. What is important is the body. In this game you aim using mouse, and the arm with gun rotates accordingly. To add realism, I decided to make it so the body bends when looking down, and moves aside(? Bends up?) when looking up. But when the body rotates the point where arm connects with body moves also. Look at the picture: ![]() See? When the angle between Point A and B changes (DIR), so does the poistion of point B, and furthermore because of that DIR changes again, and so on... So how can I find the harmony between these points? How can I find the one and only right point? ^^ If you need, these are the formulas I use: Code:
Point A - Static, its positions are Xa and Xb DIR - It is atan2(Xa-Xb,Ya-Yb) temp_atan=ATan2(-4,-5) //It's just temporarty variable, to quicken the calculations) Xb=x+5+Sin(temp_atan+dir/5) Yb=y+8+Cos(temp_atan+dir/5) (These codes above might not be perfect, as I keep finding mistakes here and there, but in any case I think I'd be able to change the finishing algorithm) I hope it is understandable. It was hellishly difficult for me to explain ^^; Thanks in advance Last edited by Maurice_Z; 02-29-2008 at 03:57 PM. |
| Sponsored Links |
|
|
|
|||||
|
Let me see if I understand:
You want the body to tilt when you aim up/down. This changes where the arm is, requiring a correction of the arm so you are still aiming at the desired location. Thinking of this in terms of vectors, you want to have two vectors determine the position of the arm/body, rather than a single vector for the arm which will determine the appearance when aiming, correct? If so, I should be able to construct the equations you need to render the arm/body correctly.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
Quote:
Either way, I don't need it anymore, as I managed to write alternate algorithm which works fine. If you want to bother though, then I'll be grateful, as I enjoy gaining new experiences . |
|
|||||
|
In the end, it will proably end up being a system of equations (with what I'm thinking). If you have a working solution, I'll probably consider it "mission accomplished"
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What Sort Of Things Did You Make When You Started VB? | Skel | Visual Basic Programming | 1 | 11-06-2007 01:47 PM |
| how to find derivative in java | sania21 | Java Help | 1 | 05-15-2007 06:35 AM |
| Linking strategy - absolute vs relative | Carrym | Search Engine Optimization | 10 | 05-09-2007 10:08 AM |
| A great find: Beginning Perl | techni68 | Perl | 0 | 01-21-2007 05:39 AM |
| 10 Things That Will Make Or Break Your Website | xXHalfSliceXx | Website Design | 10 | 01-04-2007 05:38 AM |
| John | ........ | 223.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 65%