math

Is it possible to write (a*b)+(c*d) in a way that doesn't use order of operations?

Alright, so warsow has some pretty excellent hud code with the exception that the math logic is a bit screwy. Input: a*b + c*d Interpreted as: ((d*c) + b) * a As you can see, the game does a series of operations in reverse order without regard to order of operations. Parentheses do not work in the hud code. It must be a linear ser...

How to subtract a rectangle from another?

I'm trying to determine the working area of the desktop even when the taskbar is hidden. I have two Rectangles, the screen's bounds and the taskbar's bounds. I need to subtract the taskbar's bounds Rectangle from the screen Rectangle to determine the available working area of the desktop. Basically, I want to come up with Screen.Worki...

Creating a matrix for a billboarded quad?

I'm trying to come up with a proper algorithm to create a matrix which gets the quad to face the camer straight up but I'm having difficulty. The quad I'm drawing is facing downwards, here's the code I have so far: D3DXVECTOR3 pos; pos = D3DXVECTOR3(-2.0f, 6.0f, 0.1f); D3DXMATRIX transform; D3DXMatrixTranslation(&transform, pos.x, pos....

How to formulate such problem mathematicaly? (line continuation search)

I have an array of "lines" each defined by 2 points. I am working with only the line segments lying between those points. I need to search lines that could continue one another (relative to some angle) and lie on the same line (with some offset) I mean I had something like 3 lines I solved some mathematical problem (formulation of wh...

How to describe a MATLAB function using mathematical notation?

Basically I have created two MATLAB functions which involve some basic signal processing and I need to describe how these functions work in a written report. It specifically requires me to describe the algorithms using mathematical notation. Maths really isn't my strong point at all, in fact I'm quite surprised I've even been able to de...

What's an easy way of doing powers in PHP?

I'm trying to make to make a script to help me with my maths example equation: y=(4*(x*2)^(2x+4))+4*x^2 For this to work, I just need it to understand that only (x*2) needs to be put to the power of (2x+4), and then to sub that back into the original equation, which of course you can just eval() an answer. I want to calculate the valu...

Getting a negative NaN on g++ 4.4.3, is this standard?

I have g++ 4.4.3 on Linux with Ubuntu Lucid Lynx, and I am getting a: -nan as a result. On Hardy Heron with g++ 4.3.1, I am getting all nan This is causing my text diff regression to fail, since I am using cout to print this numerical result. What is the meaning of a signed nan, and is there a way to tell the compiler that an unsig...

Issue with precision of Ruby math operations

Do you know how to fix the following issue with math precision? p RUBY_VERSION # => "1.9.1" p 0.1%1 # => 0.1 p 1.1%1 # => 0.1 p 90.0%1 # => 0.0 p 90.1%1 # => 0.0999999999999943 p 900.1%1 # => 0.100000000000023 p RUBY_VERSION # => "1.9.2" p 0.1%1 # => 0.1 p 1.1%1 # => 0.10000000000000009 p 90.0%1 # => 0.0 p 90.1%1 # => 0.099999999999994...

noob: Why divide always produces 0.0 float/integer problem?

Hello helpers! So if I have a range of numbers '0 - 1024' and I want to bring them into '0 - 255', the maths would dictate to divide the input by the maximum the input will be (1024 in this case) which will give me a number between 0.0 - 1.0. then multiply that by the destination range, (255). Which is what I want to do! But for some ...

map points between two triangles in 3D space

Hello, EDIT I don't know is it important, but destination triangle angles may be different than these of source. Does that fact makes transformation non-affine ? (i'm not sure) I have two triangles in 3D space. Given that i know (x,y,z) of point in first triangle and i know vectors V1,V2,V3. I need to find point (x',y',z'). What tra...

How to make the player slide smoothly against terrain in a game?

I'm making an isometric game. When the player tries to walk diagonally into a wall I want them to slide smoothly across it, so whatever portion of the movement would be legal is used, and anything in the direction of the normal is thrown away. Walls can be any angle, not just vertical or horizontal, and the player has 360 motion. I fe...

jquery find number of 'li' items in a 'ul' and apply some math to calculate height of 'ul'

Jquery/programming newb here. I'm trying to dynamically assign a height to a ul to force some scrolling. My method is to detect how many items are in the list and then apply some math to calculate a height of my ul (I have tried height(); but it was not giving the right number; the ul is a grid of thumbnail images, displayed inline, show...

I have a math problem and I love stackoverflow

I know it's not programming question but I thought we could all use the challenge :) Link to diagram Point A is the source of a laser. It is shinned at a single mirror and then reflected to another mirror finally arriving at point B ... see picture. The goal is to find the total distance of all the lines. I am not a student and th...

C++ Use secant method to solve function

Hi, I have a school problem but I do not understand what it actually asks. Any of you have an idea what it's really asking for? I don't need code, I just need to understand it. This is the problem: Construct a computer program that uses the Secant method to solve the problem: f(x)  =  (1+x) cos( sin(x)3 ) -  1.4   =  0 Starting with th...

Fast logistic function

I am looking for a way to implement a fast logistic function. The classic definition of logistic function is: y(x) = 1 / (1 + (1/e^x)) where ^ is exponentiation. or equally: y(x) = (e^x) / (e^x + 1) However, my special logistic function has a base E instead of e, so: y(x) = E^x / (E^x + 1) E and x in my case are 32-bit integer, fix...

what are MathJax opensource analogs for ActionScript\MXML developers?

what are MathJax opensource analogs for ActionScript\MXML developers? so to be cqapable to render strings like this J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} into stuff like this ...

Orthogonal Vectors

Given a vector V of size N, Find if there exists another vector A (of size N) such that A.V = 0 where . represents the Dot product or Inner Product ie a1*v1 + a2*v2 + a3 * v3 + ... an*vn = 0, and A >0 ie all ai are non-negative integers and all ais cannot be 0 at the same time(trivial case). Suggest an algorithm to generate a YES of NO. ...

1D multiple peak detection?

I am currently trying to implement basic speech recognition in AS3. I need this to be completely client side, as such I can't access powerful server-side speech recognition tools. The idea I had was to detect syllables in a word, and use that to determine the word spoken. I am aware that this will grealty limit the capacities for recogni...

Math me - 2d video games.

I'm a hobbyist game programmer. I only do 2d games, no 3d stuff. I don't have a math background and lots of things are tripping me up like bullet projections and angles. I took two college level Algebra courses at the local community college, but really disappointed. I got As in both, but really don't feel like I'm using any of it in...

Calculate 3D rotation of a point

How do I calculate the pitch, yaw, and roll angles for a point in 3D space? I'm working on a game where the player character must face towards an object that's flying around. ...