Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 01-18-08   #1 (permalink)
4.0ghz
 
SoaDMTGguy's Avatar
 
intel nvidia

Join Date: Mar 2005
Location: Nottingham PA
Posts: 4,929

Rep: 306 SoaDMTGguy is a proven memberSoaDMTGguy is a proven memberSoaDMTGguy is a proven memberSoaDMTGguy is a proven member
Unique Rep: 227
FAQs Submitted: 2
Folding Team Rank: 1164
Hardware Reviews: 3
Trader Rating: 15
Default Acceleration and Velocity functions for C++?

I am trying to write a C++ program that will uses acceleration and time to calculate velocity and position. Is there a library of functions that I could include to do these calculations for me, or will I have to write my own functions to calculate position and velocity in relation to acceleration and time?
__________________
Quote:
Originally Posted by PaulTa View Post
I'm like Obi wan. I just pop in and out, offer vague comments and advice, and then tell you to use the force.

System: Teh MacBook!
CPU
Intel Core 2 Duo T7500 2.2 GHz
Motherboard
Apple MacBook Pro Stock Motherboard
Memory
4 GB (2x 2 GB) G.Skill DDR2 667 MHz DDR2
Graphics Card
nVidia GeForce Go 8600 GT 128 MB
Hard Drive
120 GB Fujitsu SATA150
Sound Card
Intel Sata Rosea HD Audio
Power Supply
Apple Stock Power Adapter
Case
15" Apple Aluminum MacBook Pro Case
CPU cooling
Stock
GPU cooling
Stock
OS
OS X 10.5 Leopard / Windows XP Pro / Fedora 8
Monitor
15" Apple LED Backlit MacBook Pro Matt Display
SoaDMTGguy is offline I fold for Overclock.net Overclocked Account   Reply With Quote
Old 01-21-08   #2 (permalink)
Programmer
 
intel ati

Join Date: Aug 2006
Location: Moscow, ID
Posts: 160

Rep: 10 Safetydan Unknown
Unique Rep: 9
Folding Team Rank: 1300
Trader Rating: 1
Default

I don't know of any standardized physics libraries for c++, at least none outside of physics engines intended for games and such.

There are probably some homebrew libraries out there that you could use (I generally just google what I'm looking for to find that sort of thing) but it would also be pretty easy to make your own if all you need is basic acceleration/velocity stuff.
__________________
"He attacked everything in life with a mix of extraordinary genius and naive incompetence, and it was often difficult to tell which was which."
Douglas Adams

System: Monster v2
CPU
Q6600 G0
Motherboard
GA-P35-DS3L
Memory
2GB Crucial Ballistix
Graphics Card
Saphire Radeon x1900XTX
Hard Drive
WD 320GB
Sound Card
x-fi extreme music (modded)
Power Supply
OCZ 700W
Case
Gigabyte 3D aurora
CPU cooling
TR Ultra-120 Extreme
GPU cooling
vf900
OS
Windows XP
Monitor
2x Acer 22" WS
Safetydan is offline I fold for Overclock.net   Reply With Quote
Old 01-21-08   #3 (permalink)
Off By 340 Undecillion
 
The Bartender Paradox's Avatar
 
amd nvidia

Join Date: Oct 2004
Location: Portland, Oregon
Posts: 2,318

Rep: 306 The Bartender Paradox is a proven memberThe Bartender Paradox is a proven memberThe Bartender Paradox is a proven memberThe Bartender Paradox is a proven member
Unique Rep: 234
Folding Team Rank: 387
Hardware Reviews: 1
Trader Rating: 3
Default

I don't know C++ that well, but Going from acceleration and time to velocity and position are just a couple of simple algebraic equations in one dimension, and its not that hard to expand it to three. If your inputs for accel and time are just two numbers, then, assuming that both position and velocity are initially at 0:

Velocity = Acceleration * Time
Position= 1/2 * acceleration * (Time^2)

If velocity and position are not initially 0 then

Velocity = (Acceleration * Time) + InitialVelocity
Position= (1/2 * acceleration * (Time^2)) + (InitialVelocity * Time) + InitialPos
__________________

A rocket powered land shark attached to a giant freakin' laser beam.
Congratulations! You have found the secret text! You get a cookie.

System: My System
CPU
AMD A64 3500+ Winchester
Motherboard
DFI nF4 SLi-DR
Memory
OCZ 4000VX
Graphics Card
EVGA 7800GT
Hard Drive
Maxtor 300Gb 16Mb Buffer
Sound Card
computers make sounds?
Power Supply
OCZ PowerStream 520W
Case
None
CPU cooling
Big
GPU cooling
Bigger
OS
XP Pro
Monitor
SOYO LCD
The Bartender Paradox is offline I fold for Overclock.net Overclocked Account The Bartender Paradox's Gallery   Reply With Quote
Old 01-27-08   #4 (permalink)
New to Overclock.net
 
ninjinsamax3's Avatar
 
intel nvidia

Join Date: Oct 2007
Location: Albany, NY
Posts: 1,578

Rep: 124 ninjinsamax3 is acknowledged by manyninjinsamax3 is acknowledged by many
Unique Rep: 102
Hardware Reviews: 2
Trader Rating: 2
Default

I can write it with Java, but it should be similar, so maybe you can translate it and TBP already gave the formulas already.

Acceleration = Change of Velocity / Change of Time
With this, you cannot be wrong, so then you don't have to think about any other possibilities.

I think you need to write your own functions for it. If you need help, I can help you. C++ is similar to Java, so I know I can help you there. It might be annoying, since if there are no constants for each of them, you'll have to make the program a little more complicated though. Since you could be finding acceleration, velocity, or time.
__________________
ヤッパリ、オレわ・・・オマエのコトがマダ好きナンデス・・・。
アラガキ・ユイ、チョウカワイイっス・・・。
Program: Profit Calculator

System: kaori.
CPU
Intel Core 2 Quad Q6600 Kentsfield @ 3.42GHz
Motherboard
ASUS Maximus II Formula
Memory
2xG.SKILL 2GB DDR2 800 (PC2 6400)
Graphics Card
EVGA 512-P3-N873-AR GeForce 9800 GTX+
Hard Drive
2xWestern Digital Caviar SE16250GB (RAID 0)
Sound Card
SupremeFX X-Fi Audio Card
Power Supply
CORSAIR CMPSU-750TX 750W
Case
COOLER MASTER Centurion 5 CAC-T05-UW
CPU cooling
TRUE Black (LAPPED) + 2xSanyo Denki Ace 1011
GPU cooling
Stock & Air
OS
Microsoft XP 32bit Pro & Vista 32bit Ultimate
Monitor
SAMSUNG 2253BW Black 22"
ninjinsamax3 is offline   Reply With Quote
Old 01-27-08   #5 (permalink)
The Project Keeper
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Bel Air
Posts: 9,550
Blog Entries: 3

Rep: 278 Licht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 184
Folding Team Rank: 880
Trader Rating: 0
Default

Quote:
Originally Posted by The Bartender Paradox View Post
I don't know C++ that well, but Going from acceleration and time to velocity and position are just a couple of simple algebraic equations in one dimension, and its not that hard to expand it to three. If your inputs for accel and time are just two numbers, then, assuming that both position and velocity are initially at 0:

Velocity = Acceleration * Time
Position= 1/2 * acceleration * (Time^2)

If velocity and position are not initially 0 then

Velocity = (Acceleration * Time) + InitialVelocity
Position= (1/2 * acceleration * (Time^2)) + (InitialVelocity * Time) + InitialPos
Like he said man it isn't like its hard to make your own functions for this kind of thing.

System: Uzicht #3
CPU
Athlon X2 5200+ Windsor
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
Saphire HD 3870
Hard Drive
2x WD 160GB 7,200RPM RAID0
Sound Card
X-Fi Extreme Gamer Fatality Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
AMD Stock Cooling
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows Vista Home Premium x64 SP1
Monitor
Samsung SyncMaster 19"Wide
Licht is offline I fold for Overclock.net Overclocked Account Licht's Gallery   Reply With Quote
Old 01-30-08   #6 (permalink)
110100001101001111000
 
C-bro's Avatar
 
intel nvidia

Join Date: Jan 2006
Location: Hamilton, ON
Posts: 1,846

Rep: 288 C-bro is a proven memberC-bro is a proven memberC-bro is a proven member
Unique Rep: 219
FAQs Submitted: 6
Folding Team Rank: 241
Hardware Reviews: 9
Trader Rating: 1
Default

All you have to do is make two methods for each one. They'll both have the same name, but can take in different inputs (known as polymorphism).

Code:
 // this method would compute the case of v0 = 0
double[] findPosition(double time, double acceleration){

}

//this method would take care of the other case
double[] findPosition(double time, double acceleration, double initialPos, double intialVelocity){

}
All you do is fill in those program segments with your formulas, and return the result as an array with the first element being velocity and second element being position. You also don't have to worry about the methods having the same name, because the computer will know which method to call depending on your inputs.

System: RAID0R
CPU
Intel E2180 3.33GHz
Motherboard
Asus P5K-E/WIFI-AP vMod
Memory
2GB Kingmax DDR2-1066
Graphics Card
EVGA 8800GT
Hard Drive
2x250GB WD+500GB 7200.11
Sound Card
SB Audigy 2
Power Supply
Corsair CMPSU-550VX
CPU cooling
Arctic Cooling Freezer 7 Pro
GPU cooling
Zalman VF900-Cu
OS
Windows Vista Business 32-Bit
Monitor
HP F2105 21" & Samsung 712N
C-bro is offline I fold for Overclock.net Overclocked Account C-bro's Gallery   Reply With Quote
Old 01-31-08   #7 (permalink)
Database Developer
 
mirunit's Avatar
 
intel nvidia

Join Date: Dec 2004
Location: North Carolina
Posts: 746

Rep: 35 mirunit is acknowledged by some
Unique Rep: 32
Trader Rating: 0
Default

http://www.mathtools.net/C_C__/Calculus/index.html

Try that, you should be able to take the derivatives / integrals.

f(x) = pos.
f'(x) = vel.
f''(x) = acc.
__________________
A fan of anything which uses AES, .NET, Relational Databases, RAID arrays, water cooling, HSDPA, GPS, x64 or a BMW engine.

System: Rep My Thug
CPU
Intel Q6600 @ 3.6 ghz
Motherboard
EVGA 680i SLI 775 A1
Memory
2x2GB Corsair XMS2 @ 900 mhz
Graphics Card
2x 9800 GTX (SLI) + 7950 GT
Hard Drive
2x 7200RPM Raid0
Sound Card
Onboard 7.1 Realtek HD
Power Supply
750w Silverstone
Case
Black Dragon w/ Window
CPU cooling
DTEK Fuzion Block
GPU cooling
Stock
OS
Windows Vista x64 SP1
Monitor
2x 21" 16:10 LCD's
mirunit is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 07:55 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.24457 seconds with 8 queries