math

Math logic (basic trig) in a game, what is this code doing?

I'm trying to better understand what exactly this code is doing. It's written in Objective-C, but should be familiar to anyone with a C background. What exactly are sin/cos mathematics doing here? Also, does anyone have a good recommendation for learning trig for gaming concepts such as these? for (int i = 0; i < GAME_CIRCLES; i++) { p...

Count up and down elegantly

I'm trying to make a flashing object, i.e., increment it's alpha value from 0 to 255 (gradually) and then back down to 0, and repeat. Is there a way I can do this without using some boolean? Getting it to increment is easy: alpha = time.elapsed()%256; But what's a nice way to get it to count back down again after that? ...

Algorithm for solving set problem

If I have a set of values (which I'll call x), and a number of subsets of x: What is the best way to work out all possible combinations of subsets whose union is equal to x, but none of whom intersect with each other. An example might be: if x is the set of the numbers 1 to 100, and I have four subsets: a = 0-49 b = 50-100 c = 50-75...

Solving partial differential equations using C#

I am working on a project (C# and .NET Framework) which requires me to solve some partial differential equations. Are there any specific libraries based on .NET Framework that I could see and make my work simpler? I have worked with MATLAb and solving partial differential equations is very straightforward there. How can I solve this pro...

Complex number notation

My DotNET application has a limited scripting language build in (modelled loosely on VBScript) mainly for post-processing numbers, points and vectors. I've just added support for complex numbers, but I'm struggling with the notation. I don't want to use the A + Bi notation, since it is not a clear division if A or B are defined as equat...

Prerequisites for understanding Wavelet theory

I have a degree in computer science and I have taken the following math courses. Calculus I Calculus II Discrete Mathematics and Number Theory Linear Algebra Probability Logic Automata Theory What other courses should I take in order to prepare for studying wavelets, with a focus of implementing wavelet transforms? EDIT: Looks like...

Get z depth from 4 vertices of a face

How can I z-order the faces of a 3d object just using the 4 vertices of each of its faces? I've tried using a z-buffer where I store the average z value of each face; this works great most of the times, but fails when an object have large and small faces. I'm building a small 3d-engine in flash, just for the fun of learning, so the only...

get number between 0 and 1 from number between 0 and n

How can I calculate values between 0 and 1 from values between 0 and n. E.g. I have items with "click count" and want to get "importance" (a float between 0 and 1) from that. My attempt: importance = 1-1/count gives bad results, since the values don't distribute well… ...

Calling atan function on Blackberry 4.2 JDE

Hi there. I need to calculate the arc tan value from my Blackberry Java app. Unfortunately, the blackberry 4.2 api doesn't have the Math.atan() function. Heaven knows why, but that's the Blackberry API for you. Version 4.6 of the Blackberry JDE has it, but not 4.2. Does anyone know of a workaround to calculate atan? ...

C++ Cosine Problem

Hello, I have the following code using C++: double value = .3; double result = cos(value); When I look at the values in the locals window for "value" it shows 0.2999999999 Then, when I get the value of "result" I get: 0.95533648912560598 However, when I run cos(.3) on the computers calculator I get: .9999862922474 So clearly there...

Algorithm for moving a point around an arbitrary non self-crossing closed polygon in N time

I'm looking for an algorithm that would move a point around an arbitrary closed polygon that is not self-crossing in N time. For example, move a point smoothly around a circle in 3 seconds. ...

Calculation error - need help!

Hello, I need to ask someone for a big favor. What you see in the code below are my calculations for train movement for a train game I am writing. There is a problem with the calculations, but I just can't seem to find it. The problem seems to be located in this code: if($trainRow['direction'] == '-') { $trackUnitCount = ...

Calculate net mask and subnet address from broadcast and address inside subnet

Hi, i'm need to calculate net mask and subnet addr using broadcast addr and host address from this subnet. I must use only bitwise operations not comparing of string representation, sysadmin tools and so on. I have some formulas for calculating addresses. but i dont know, how using it with my source data. ^ -- is bitwise xor ~ -- ne...

How does one make a Zip bomb?

This question about zip bombs naturally led me to the Wikipedia page on the topic. The article mentions an example of a 45.1 kb zip file that decompresses to 1.3 exabytes. What are the principles/techniques that would be used to create such a file in the first place? I don't want to actually do this, more interested in a simplified "how...

Need help converting iterative pattern into formula

var = 8 itr 1: var == 8 (8 * 1) itr 2: var == 24 (8 * 3) itr 3: var == 48 (8 * 6) itr 4: var == 80 (8 * 10) itr 5: var == 120 (8 * 15) Pattern: (var * (last multiplier + current iteration)) Basically I want to get the result of formula(itr) without having to iterate up to itr. ...

Should I get a math degree or a CS degree?

I'm 18 years old and going to community college. I got an A+ in my data structures class, but the biggest thing I've ever programmed on my own was a tool to solve a 3d maze toy of my brother's. I'm a little worried that I don't have enough passion for programming to succeed in it. Majoring in math would give me time to try out open so...

Determine position in front of 3D plane (cartesian math)

Hi there, I have a planar element in 3D space that I've rotated on the x, y and z axis. I'm positioning a 3D camera in front of the planar but I need to find a way to calculate the x, y, z of the camera. I'm trying to figure out how to place the camera at x distance from the planes face. There's obviously a bit of trig involved but for...

How to prove by induction that a program does something?

I have a computer program that reads in an array of chars that operands and operators written in postfix notation. The program then scans through the array works out the result by using a stack as shown : get next char in array until there are no more if char is operand push operand into stack if char is operator a = pop from stack ...

Increase value over time using mathematical algorithm

I am writing a test tool which places a large amount of load on a network service. I would like this tool to start with little load and gradually increase over time. I am sure that there is some triganometry which can do this sort of calculation in one line of code but I am not a math guru (yet). Is there some sort of library (or simple ...

Calculate brute force size dynamically?

How you could calculate size of brute force method dynamically? For example how many iterations and space would take if you printed all IPv6 addresses from 0:0:0:0:0:0:0:0 - ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff to file? The tricky parts are those when length of line varies. IP address is only example. Idea is that you give the forma...