Topic: Anyone a math wiz here?  (Read 2183 times)

0 Members and 1 Guest are viewing this topic.

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Anyone a math wiz here?
« on: August 07, 2010, 10:19:52 pm »
Okay guys, I need a favor.

I'm trying to wrap my head around some Bezier math and I can't find any reference to anything I need.

So, suppose I have a set of coordinates:
(x,y)
0,90
1,90
2,90
3,45
8,30
15,15
16,0

When charted and interpolated linearly the chart looks something like this.


Now, I want to do something like smoothing approximation - Something that would look like this.


Now, What I need to do is grab the Y-coordinate of a point on that interpolation when the X-coordinate is known.
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Anyone a math wiz here?
« Reply #1 on: August 07, 2010, 10:23:41 pm »
I wouldn't smooth the chart myself.  It will make finding the in between easier and you don't lose specific points like you did on your chart.  Look at X=3, the y changes between the normal and smoothed chart.  Doing a spline is fine but it has to keep the fixed points that you build the spline from I would think.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Anyone a math wiz here?
« Reply #2 on: August 07, 2010, 10:28:17 pm »
I'm alright with having the approximation values not neededly coincide directly with the values given. A linear interpretation (each data-point is guaranteed to be in the right place with linear interpolation) might be okay if a smoothed interpolation is too much off-key.
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Anyone a math wiz here?
« Reply #3 on: August 07, 2010, 10:45:54 pm »
now, I would say, make a function that would run a chart for each table that is needed.  You call the function needed for the chart needed.  That way, you can run the math however it is needed to get the best results.  We will work a few numbers here (the little 'un) and see if we can get a formula that might work for the example and a generic one that might work on more also.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Anyone a math wiz here?
« Reply #4 on: August 07, 2010, 10:46:50 pm »
Oh how I love you, marstone :-D.
I'm chewing on something myself.
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline Sirgod

  • Whooot Master Cattle Baron
  • Global Moderator
  • Vice Admiral
  • *
  • Posts: 27844
  • Gender: Male
Re: Anyone a math wiz here?
« Reply #5 on: August 07, 2010, 10:48:44 pm »
The point at 2.5 would be 67.5 or Y = 67.5

Is that what you are asking?

Stephen
"You cannot exaggerate about the Marines. They are convinced to the point of arrogance, that they are the most ferocious fighters on earth - and the amusing thing about it is that they are."- Father Kevin Keaney, Chaplain, Korean War

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Anyone a math wiz here?
« Reply #6 on: August 07, 2010, 10:50:04 pm »
I'm asking What would be the function to find that answer? how did you get 67.5?
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline Sirgod

  • Whooot Master Cattle Baron
  • Global Moderator
  • Vice Admiral
  • *
  • Posts: 27844
  • Gender: Male
Re: Anyone a math wiz here?
« Reply #7 on: August 07, 2010, 11:04:43 pm »
Ahh, that was easy, divided 45 by 2 which I got from the points 2 and 3, then added it to 45.

That gave me the middle point for 2.5 .

If say you wanted a point at 2.25 or 2.75, you would just divide by 4, and add appropriately.

Stephen
"You cannot exaggerate about the Marines. They are convinced to the point of arrogance, that they are the most ferocious fighters on earth - and the amusing thing about it is that they are."- Father Kevin Keaney, Chaplain, Korean War

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Anyone a math wiz here?
« Reply #8 on: August 07, 2010, 11:06:40 pm »
That is linear interpolation, basically. Which would be fine if I needed to find Y of a known X point on the first graph, but I need to know how to find Y on a known X when the data has been smoothed over.
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Anyone a math wiz here?
« Reply #9 on: August 07, 2010, 11:24:24 pm »
give us a day or so, other games are taking some time away from being able to work on it right away.   It really shouldn't be that tough of a problem (just way to many years out of math for myself, looking at getting a refresher at the university tho).

Starting to read some source code from Plane shift also.  getting a feel for it.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline manitoba1073

  • FLEET ADMIRAL OF THE YARDS
  • Lt. Commander
  • *
  • Posts: 1119
  • Gender: Male
    • manitobashipyards
Re: Anyone a math wiz here?
« Reply #10 on: August 07, 2010, 11:41:31 pm »

 The answer is 42.  :laugh: :laugh: :laugh:



Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Anyone a math wiz here?
« Reply #11 on: August 08, 2010, 01:15:29 am »
Okay, here's what I'm doing: I'm building a Spline in 3ds max with vertices at the location given. I'm then smoothing it with the built in NURMS system with 2 Iterations. I'm then going to record the location of each of the NEW vertices. We will then interpolate linearly between them all. Basically I'm tripling our dataset.
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline Tus-XC

  • Capt
  • XenoCorp® Member
  • Commander
  • *
  • Posts: 2789
  • Gender: Male
Re: Anyone a math wiz here?
« Reply #12 on: August 08, 2010, 02:34:43 am »
grab a  ti 83/89 etc (or use matlab or something) it has other methods which will pop out an equation to fit your points ;)
Rob

"Elige Sortem Tuam"

Offline AcePylut

  • Captain
  • *
  • Posts: 5706
  • Gender: Male
  • Bear Down, Chicago Bears
Re: Anyone a math wiz here?
« Reply #13 on: August 08, 2010, 01:06:08 pm »
Well, since you're extrapolating a curve from some data points, the curve doesn't match those data points when you have known data points... so guesstimate what the Y value is, and it will be as accurate as any other method.
If you care about the environment, it's better to eat a Salad in a Hummer than a Cheeseburger in a Prius.