• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
winsrp

need help on a simple math equation.

9 posts in this topic

Given X a number from -1 to 1...

I need a formula that returns me Y, also in the -1 to 1 range, but with the following pattern

[attachment=9470:pattern.png]

with the matches of
when x = -1 then y = -1
when x = -0.5 then y = -0.5
when x = 0 then y = 0
when x = 0.5 then y = 0.5
when x = 1 then y = 1

everything in between those values must follow the pattern

thanks in advance and regards,

Winsrp
0

Share this post


Link to post
Share on other sites
[img]http://public.gamedev.net//public/style_emoticons/default/mellow.png[/img] holy crap, that was fast!!, let me test it out a bit, and I'll let you know.
1

Share this post


Link to post
Share on other sites
uhhh great results, using A from 0 to 0.17 it gives me great variation... THANKS A LOT!!!
0

Share this post


Link to post
Share on other sites
@Brother Bob

Fascinating! I'd be quite interested to learn how you've managed to derive the formula from the OP's data. Could you perhaps elaborate a little?
0

Share this post


Link to post
Share on other sites
[quote name='Brother Bob' timestamp='1339687417' post='4949176']
Without any particular constraint on the values (except the few selected points) other than it should follow the pattern, then y=x-A*sin(x*pi*2) gives a close match. The points match exactly, and tweak the constant A to match the desired curvature.
[/quote]

How did you come up with this so fast? O__o
0

Share this post


Link to post
Share on other sites
It's a mostly linear function on the form y=x. If you remove the linear component you have some periodic oscillating residual, which is close to a sine wave. The points where he constrained the curve just happened to coincide with the zero-crossing points of a sine wave; zero at x=-1, x=-0.5 and x=0. Edited by Brother Bob
0

Share this post


Link to post
Share on other sites
Tristan

its not too hard to know why he got it. I was thinking along the lines of xsin(2*pi*x) but that didnt match at all (don't know why that sprang). by having -Asin(2*pi*x) it will be 0 at +- .5 and 1 (since sin(pi) and sin(2*pi) is 0 leaving x + 0, in Bobs original equation

when it is between 0 and .5 it will minus off in a sinusoidal fashion, the same as it does adding between .5 and 1
0

Share this post


Link to post
Share on other sites
May I?
The OP:s graph looks like a wave. That means sine/cosine functions may be usable. But that is not going upwards. You can make in go upwards if you add a function that goes upward. Like a simple linear function. According to the OP's graph, an y=x graph would definitely go through all the points the OP wants.

So what if we add the y=x function to a sine function?
There's a problem with that, a sine function y=x won't intersect the points where the OP wants.
BUT: The frequency of a sine function can be controlled by it's argument. A greater multiplier of x as the argument means bigger frequency (or less wavelength), smaller means smaller.

The wavelength of a sine function is 2*PI.

So to decrease it to the desired 1 unit of wavelength (wavelength is the up and down of a wave, that's repeated), we have to increase the argument's multiplier. That means we have to use 2*PI. (If you use a calculator, you can see that if you insert the appropriate x coordinates, you get the desired zeros for the sine, and the desired points in the final function).

One problem remains. Sine goes up first, not down. So, we can multiply the sine part of the final function with -1.

So, you got your equation.

Sorry, a drunk post [img]http://public.gamedev.net//public/style_emoticons/default/wacko.png[/img]



Anyway, manipulating sine/cosine function is quite easy to visualize.
If you multiple sine/cosine with a function, the "signed height of the bumps" will touch the function you multiply sine/cosine with.
If you add a function to sine/cosine, it's like sine/cosine sits on top of the function.

I hope that's clear, and sorry for posting drunk.. Edited by szecs
1

Share this post


Link to post
Share on other sites
Thank you all for these elaborate and insightful replies. (Whether they were written down whilst being intoxicated or not.)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0