View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:33 am



Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next
 DrawLine() 
Author Message
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: DrawLine()
Now we have a laser sight for artillery/grenades(?).
You are a genius.


Thu Sep 24, 2009 8:57 am
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: DrawLine()
Yes we do. Although it only works with a single weapon because it needs the gun's FireVelocity.


Thu Sep 24, 2009 9:09 am
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: DrawLine()
Could work with grenades at least.
Right?
Couldn't you just make it so that it changes the fire velocity by how long the fire button is held?


Thu Sep 24, 2009 9:16 am
Profile WWW
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: DrawLine()
Kyred wrote:
Daman wrote:
Kyred wrote:
A Riemann Sum is used to approximate an integral. Newton's method is used to approximate a derivative. Using either of these in Lua, you could adapt the DrawLine() method to efficiently drawing something such as a parabola, something that would be useful for showing the path a projectile will fly before you fire it.

So actually, Riemann Sums do have something to do with this.

uh nope it doesn't because you'd be a fuc­king idiot to use riemann sums to draw a trajectory
you don't find the area under a curve to draw a trajectory sorry you're completely wrong
You can integrate velocity with respect to time to get a position function.

The physics equation y = y0 + y0*t + 1/2*a*t^2 is created this way (integrate v = v0 + at with respect to 't'), which is an equation for trajectory when 'a' is negative. Plug in a projectile's velocity function into the integrand, and you will get a basic parabola to model the trajectory. Then you can use the line algorithm to draw the trajectory.


sorry you're still not using a riemann sum, just integrals

dominated

Quote:
ProjektTHOR wrote:
I think his point was "Stop being a Wikipedia scholar."

For the record, I am currently in my 4th (and last :D) semester of calculus, and will be taking differential equations after that. I typed out all this from memory, since I am forced to use some of this stuff on almost a daily basis.


wow you're hard

the rest of us have already done that


Thu Sep 24, 2009 11:32 am
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: DrawLine()
CrazyMLC wrote:
Could work with grenades at least.
Right?
Couldn't you just make it so that it changes the fire velocity by how long the fire button is held?
Yes, but that would still need the min and max throw velocities to work, and they are grenade specific.
Edit:
Image


Thu Sep 24, 2009 11:41 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: DrawLine()
Daman wrote:
sorry you're still not using a riemann sum, just integrals

dominated

The difference between a Riemann sum and an integral is the fact that an integral is a Riemann sum where the upper limit of the summation approaches infinity. If you were to try to write a function for an integral, in Lua, with an infinite number of sums, then you would have an infinite loop.

Instead, you have to approximate the integration by defining a finite number for the summation's upper limit. The higher the upper limit, the more accurate the approximation. Which means you would have a Riemann sum. ♥♥♥♥, how could you have passed Calc 1 without knowing this?


Thu Sep 24, 2009 5:42 pm
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: DrawLine()
piipu wrote:
Yes, but that would still need the min and max throw velocities to work, and they are grenade specific.
Edit:
Image

Sweet.
Does it do bounces?
Like banking a grenade off of a wall.


Thu Sep 24, 2009 5:52 pm
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: DrawLine()
Nope. And I can't be assed to go through all that trouble since it wouldn't work anyways with CC's collisions.


Thu Sep 24, 2009 5:54 pm
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: DrawLine()
Kyred wrote:
Daman wrote:
sorry you're still not using a riemann sum, just integrals

dominated

The difference between a Riemann sum and an integral is the fact that an integral is a Riemann sum where the upper limit of the summation approaches infinity. If you were to try to write a function for an integral, in Lua, with an infinite number of sums, then you would have an infinite loop.

Instead, you have to approximate the integration by defining a finite number for the summation's upper limit. The higher the upper limit, the more accurate the approximation. Which means you would have a Riemann sum. fudge, how could you have passed Calc 1 without knowing this?


if you try to write a function for any approximation with an infinite number as accuracy you're going to get an infinite loop

sorry but there's no point arguing when you're just going to red herring left and right

point is that you're not going to use the area acquired by calculating the Riemann sum in plotting a trajectory, you're going to use points on a line

Hopefully that is easier for you to understand, as it doesn't involve a bit of calculus.


Thu Sep 24, 2009 9:21 pm
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: DrawLine()
Daman wrote:
if you try to write a function for any approximation with an infinite number as accuracy you're going to get an infinite loop

:???: That is what i just said:

Kyred wrote:
you have to approximate the integration by defining a finite number for the summation's upper limit.


Daman wrote:
point is that you're not going to use the area acquired by calculating the Riemann sum in plotting a trajectory, you're going to use points on a line
Apparently, you forgot one important fact about the area. The area under a velocity curve gives the net displacement that occurred on the interval [a,b]. You can easily vectorize this displacement into x and y and then add them, as a vector, to the initial position, thereby giving you "points on a line".

Consider this example, involving the given velocity curve v(t):
Image
In the above picture, the total area s(t) is calculated by adding up the areas* of equally spaced intervals (deltaX) from x = a to eventually x = b. Each sum given by v(Xi)*deltaX gives an area that represents the approximate displacement that will occur between a and Xi (note that Xi represents some point in time, not position). Therefore, each value of Xi (X1, X2,...,X6,X7) can be used to calculate a position of a respective laser sight dot (dot 1, dot 2,...,dot 6, dot 7). Just add the calculated displacements (in vector form) to the position of the Actor.

I honestly cannot see how you cannot understand this simple concept :???:. Yes, you can plot a trajectory using a Riemann Sum.

*Yes, I do realize that I accidentally left out the part of the boxes over the curve in the picture. Since the sum uses right endpoints the actual calculated area would be an overestimation.


Last edited by Kyred on Fri Sep 25, 2009 5:35 am, edited 1 time in total.



Fri Sep 25, 2009 5:04 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: DrawLine()
As much as I know you guys are having a great time quibbling, probably the easiest technique for estimating a trajectory is to just simulate CC's physics. Do a for loop, adding the gravity to the velocity and then adding the velocity, divided by 3, to the position.
Also, cookie to whoever figures out why the velocity has to be divided by 3 for this to work. I still haven't figured it out, but it was the only number that worked. Try storing an object's last position and finding the difference between that and its current position - it is always a third of the object's velocity, give or take a few decimals.


Fri Sep 25, 2009 5:30 am
Profile WWW
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: DrawLine()
You divide by 3 to get the average.


Fri Sep 25, 2009 5:34 am
Profile WWW
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: DrawLine()
CrazyMLC wrote:
You divide by 3 to get the average.
Average among what? Never mind. I've argued enough for one thread :-?


Last edited by Kyred on Fri Sep 25, 2009 6:00 am, edited 1 time in total.



Fri Sep 25, 2009 5:37 am
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: DrawLine()
TheLastBanana wrote:
Do a for loop, adding the gravity to the velocity and then adding the velocity, divided by 3, to the position.


Fri Sep 25, 2009 5:50 am
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: DrawLine()
TheLastBanana wrote:
As much as I know you guys are having a great time quibbling, probably the easiest technique for estimating a technique is to just simulate CC's physics. Do a for loop, adding the gravity to the velocity and then adding the velocity, divided by 3, to the position.
Also, cookie to whoever figures out why the velocity has to be divided by 3 for this to work. I still haven't figured it out, but it was the only number that worked. Try storing an object's last position and finding the difference between that and its current position - it is always a third of the object's velocity, give or take a few decimals.


Sounds like CC's rate of sim updates per visible frame.

That or some shenanigans with the run rate of Lua compared to the engine.


Fri Sep 25, 2009 2:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 32 posts ]  Go to page Previous  1, 2, 3  Next

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.064s | 13 Queries | GZIP : Off ]