Search Results

Search found 196 results on 8 pages for 'maths'.

Page 1/8 | 1 2 3 4 5 6 7 8  | Next Page >

  • Resuming blogging activities and a maths question

    - by ali.mukadam
    Resuming my blogging activities and unlike Dumbledore, I do not have a pensieve to review my thoughts and put them in order. On the other hand, thinking of maths problems somehow seem to make them clearer. So before I start writing long-winding blog posts, here's one I was given 16 years ago: The length of a rectangle is 6 cm smaller than its width. If the area of the rectangle is 16, what is its perimeter? Hint: Solvable in 5 lines or less. Cheers, Ali

    Read the article

  • Is it possible to learn maths via programming, or you should learn maths for programming?

    - by SAFAD
    I am not the best in maths, not very horrid either, but lower than the average, I've always been thinking to improve my maths, but schools and books didn't do the job because I get bored too fast. The only thing I don't get bored with is coding and gaming, so I thought what if coding a program that solves mathematical problems will help me understand maths better, most of these problems are limits (calculus), functions, Differential calculus, and some other subjects (I already said am not that good) similar to the previous noted. My question is: Am I able to achieve a better knowledge in maths if I do some specific program coding, and if possible, is physics possible that way too? Or am I wrong and Maths should be learned before programming to help improve my coding? P.S : C++ is the preferred language.

    Read the article

  • recurrence maths

    - by Tony
    Hi all! I have the following: T(n) <= c floor(n/2) + c ceiling(n/2) + 1 = cn + 1 T(n) = O(n) I don't understand how it gets from the first equation to the second equation? What part of the maths am I missing to understand how this comes to be? Is it done using 'Simplifying Equations' or some other rules? Can someone help me?

    Read the article

  • C# Vector maths questions

    - by Mark
    Im working in a screen coordinate space that is different to that of the classical X/Y coordinate space, where my Y direction goes down in the positive instead of up. Im also trying to figure out how to make a Circle on my screen always face away from the center point of the screen. If the center point of my screen is at x(200) y(300) and the point of my circle's center is at x(150) and y(380) then I would like to calculate the angle that the circle should be facing. At the moment I have this: Point centerPoint = new Point(200, 300); Point middleBottom = new Point(200, 400); Vector middleVector = new Vector(centerPoint.X - middleBottom.X, centerPoint.Y - middleBottom.Y); Vector vectorOfCircle = new Vector(centerPoint.X - 150, centerPoint.Y - 400); middleVector.Normalize(); vectorOfCircle.Normalize(); var angle = Math.Acos(Vector.CrossProduct(vectorOfCircle, middleVector)); Console.WriteLine("Angle: {0}", angle * (180/Math.PI)); Im not getting what I would expect. I would say that when I enter in x(150) and y(300) of my circle, I would expect to see the rotation of 90 deg, but Im not getting that... Im getting 180!! Any help here would be greatly appreciated. Cheers, Mark

    Read the article

  • maths: motion depending on time

    - by clamp
    hello, i have a mathematical problem: i have a function where the only parameter is the current time. the return should be a position which is used to place an object on a certain place. int position(int time) { int x = 0; //TODO implement x depending on time return x; } so basically the function is called every frame to put the object in motion. the motion should look like this (this is the actual question): a linear motion for time A, the object moves at constant speed no motion for time B, the object is stopped repeat at 1. thanks!

    Read the article

  • Estimate angle to launch missile, maths question

    - by Jonathan
    I've been working on this for an hour or two now and my maths really isn't my strong suit which is definitely not a good thing for a game programmer but that shouldn't stop me enjoying a hobby surely? After a few failed attempts I was hoping someone else out there could help so here's the situation. I'm trying to implement a bit of faked intelligence when the A.I fires it's missiles at a target in a 2D game world. By predicting the likely position the target will be in given it's current velocity and the time it will take the missile to reach it's target. I created an image to demonstrate my thinking: http://i.imgur.com/SFmU3.png which also contains the logic I use for accelerating the missile after launch. The ship that fires the missile can fire within a total of 40 degree angle, 20 either side of itself, but this could likely become variable. My current attempt was to break the space between the two lines into segments which match the targets width. Then calculate the time it would take the missile to get to that location using the formula. So for each iteration of this we total up the values and that tells us the distance travelled, ad it would then just need compared to distance to the segment. startVelocity * ((startVelocity * acceleration)^(currentframe-1) So for example. If we start at a velocity of 1f/frame with an acceleration of 0.1f the formula, at frame 4, would be 1 * (1.1^3) = 1.331 But I quickly realized I was getting lost when trying to put this into practice. Does this seem like a correct starting point or am I going completely the wrong way about it? Any pointers would help me greatly. Maths really isn't my strong suit so I get easily lost in these matters and don't even really know a good phrase to search for with this. So I guess in summary my question is more about the correct way to approach this problem and any additional code samples on top of that would be great but I'm not averse to working out the complete code from helpful pointers.

    Read the article

  • Car-like Physics - Basic Maths to Simulate Steering

    - by Reanimation
    As my program stands I have a cube which I can control using keyboard input. I can make it move left, right, up, down, back, fourth along the axis only. I can also rotate the cube either left or right; all the translations and rotations are implemented using glm. if (keys[VK_LEFT]) //move cube along xAxis negative { globalPos.x -= moveCube; keys[VK_RIGHT] = false; } if (keys[VK_RIGHT]) //move cube along xAxis positive { globalPos.x += moveCube; keys[VK_LEFT] = false; } if (keys[VK_UP]) //move cube along yAxis positive { globalPos.y += moveCube; keys[VK_DOWN] = false; } if (keys[VK_DOWN]) //move cube along yAxis negative { globalPos.y -= moveCube; keys[VK_UP] = false; } if (FORWARD) //W - move cube along zAxis positive { globalPos.z += moveCube; BACKWARD = false; } if (BACKWARD) //S- move cube along zAxis negative { globalPos.z -= moveCube; FORWARD = false; } if (ROT_LEFT) //rotate cube left { rotX +=0.01f; ROT_LEFT = false; } if (ROT_RIGHT) //rotate cube right { rotX -=0.01f; ROT_RIGHT = false; } I render the cube using this function which handles the shader and position on screen: void renderMovingCube(){ glUseProgram(myShader.handle()); GLuint matrixLoc4MovingCube = glGetUniformLocation(myShader.handle(), "ProjectionMatrix"); glUniformMatrix4fv(matrixLoc4MovingCube, 1, GL_FALSE, &ProjectionMatrix[0][0]); glm::mat4 viewMatrixMovingCube; viewMatrixMovingCube = glm::lookAt(camOrigin,camLookingAt,camNormalXYZ); ModelViewMatrix = glm::translate(viewMatrixMovingCube,globalPos); ModelViewMatrix = glm::rotate(ModelViewMatrix,rotX, glm::vec3(0,1,0)); //manually rotate glUniformMatrix4fv(glGetUniformLocation(myShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &ModelViewMatrix[0][0]); movingCube.render(); glUseProgram(0); } The glm::lookAt function always points to the screens centre (0,0,0). The globalPos is a glm::vec3 globalPos(0,0,0); so when the program executes, renders the cube in the centre of the screens viewing matrix; the keyboard inputs above adjust the globalPos of the moving cube. The glm::rotate is the function used to rotate manually. My question is, how can I make the cube go forwards depending on what direction the cube is facing.... ie, once I've rotated the cube a few degrees using glm, the forwards direction, relative to the cube, is no longer on the z-Axis... how can I store the forwards direction and then use that to navigate forwards no matter what way it is facing? (either using vectors that can be applied to my code or some handy maths). Thanks.

    Read the article

  • GLM Velocity Vectors - Basic Maths to Simulate Steering

    - by Reanimation
    UPDATE - Code updated below but still need help adjusting my math. I have a cube rendered on the screen which represents a car (or similar). Using Projection/Model matrices and Glm I am able to move it back and fourth along the axes and rotate it left or right. I'm having trouble with the vector mathematics to make the cube move forwards no matter which direction it's current orientation is. (ie. if I would like, if it's rotated right 30degrees, when it's move forwards, it travels along the 30degree angle on a new axes). I hope I've explained that correctly. This is what I've managed to do so far in terms of using glm to move the cube: glm::vec3 vel; //velocity vector void renderMovingCube(){ glUseProgram(movingCubeShader.handle()); GLuint matrixLoc4MovingCube = glGetUniformLocation(movingCubeShader.handle(), "ProjectionMatrix"); glUniformMatrix4fv(matrixLoc4MovingCube, 1, GL_FALSE, &ProjectionMatrix[0][0]); glm::mat4 viewMatrixMovingCube; viewMatrixMovingCube = glm::lookAt(camOrigin, camLookingAt, camNormalXYZ); vel.x = cos(rotX); vel.y=sin(rotX); vel*=moveCube; //move cube ModelViewMatrix = glm::translate(viewMatrixMovingCube,globalPos*vel); //bring ground and cube to bottom of screen ModelViewMatrix = glm::translate(ModelViewMatrix, glm::vec3(0,-48,0)); ModelViewMatrix = glm::rotate(ModelViewMatrix, rotX, glm::vec3(0,1,0)); //manually turn glUniformMatrix4fv(glGetUniformLocation(movingCubeShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &ModelViewMatrix[0][0]); //pass matrix to shader movingCube.render(); //draw glUseProgram(0); } keyboard input: void keyboard() { char BACKWARD = keys['S']; char FORWARD = keys['W']; char ROT_LEFT = keys['A']; char ROT_RIGHT = keys['D']; if (FORWARD) //W - move forwards { globalPos += vel; //globalPos.z -= moveCube; BACKWARD = false; } if (BACKWARD)//S - move backwards { globalPos.z += moveCube; FORWARD = false; } if (ROT_LEFT)//A - turn left { rotX +=0.01f; ROT_LEFT = false; } if (ROT_RIGHT)//D - turn right { rotX -=0.01f; ROT_RIGHT = false; } Where am I going wrong with my vectors? I would like change the direction of the cube (which it does) but then move forwards in that direction.

    Read the article

  • Algorithm for querying linearly through a non-linear list of questions

    - by JoshLeaves
    For a multiplayers trivia game, I need to supply my users with a new quizz in a desired subject (Science, Maths, Litt. and such) at the start of every game. I've generated about 5K quizzes for each subject and filled my database with them. So my 'Quizzes' database looks like this: |ID |Subject |Question +-----+------------+---------------------------------- | 23 |Science | What's water? | 42 |Maths | What's 2+2? | 99 |Litt. | Who wrote "Pride and Prejudice"? | 123 |Litt. | Who wrote "On The Road"? | 146 |Maths | What's 2*2? | 599 |Science | You know what's cool? |1042 |Maths | What's the Fibonacci Sequence? |1056 |Maths | What's 42? And so on... (Much more detailed/complex but I'll keep the exemple simple) As you can see, due to technical constraints (MongoDB), my IDs are not linear but I can use them as an increasing suite. So far, my algorithm to ensure two users get a new quizz when they play together is the following: // Take the last played quizzes by P1 and P2 var q_one = player_one.getLastPlayedQuizz('Maths'); var q_two = player_two.getLastPlayedQuizz('Maths'); // If both of them never played in the subject, return first quizz in the list if ((q_one == NULL) && (q_two == NULL)) return QuizzDB.findOne({subject: 'Maths'}); // If one of them never played, play the next quizz for the other player // This quizz is found by asking for the first quizz in the desired subject where // the ID is greater than the last played quizz's ID (if the last played quizz ID // is 42, this will return 146 following the above example database) if (q_one == NULL) return QuizzDB.findOne({subject: 'Maths', ID > q_two}); if (q_two == NULL) return QuizzDB.findOne({subject: 'Maths', ID > q_one}); // And if both of them have a lastPlayedQuizz, we return the next quizz for the // player whose lastPlayedQuizz got the higher ID if (q_one > q_two) return QuizzDB.findOne({subject: 'Maths', ID > q_one}); else return QuizzDB.findOne({subject: 'Maths', ID > q_two}); Now here comes the real problem: Once I get to the end of my database (let's say, P1's last played quizz in 'Maths' is 1056, P2's is 146 and P3 is 1042), following my algorithm, P1's ID is the highest so I ask for the next question in 'Maths' where ID is superior to 1056. There is nothing, so I roll back to the beginning of my quizz list (with a random skipper to avoid having the first question always show up). P1 and P2's last played will then be 42 and they will start fresh from the beginning of the list. However, if P1 (42) plays against P3 (1042), the resulting ID will be 1056...which P1 already played two games ago. Basically, players who just "rolled back" to the beginning of the list will be brought back to the end of the list by players who still haven't rolled back. The rollback WILL happen in the end, but it'll take time and there'll be a "bottleneck" at the beginning and at the end. Thus my question: What would be the best algorith to avoid this bottleneck and ensure players don't get stuck endlessly on the same quizzes? Also bear in mind that I've got some technical constraints: I can't get a random question in a subject (ie: no "QuizzDB.findOne({subject: 'Maths'}).skip(random());"). It's cool to skip on one to twenty records, but the MongoDB documentation warns against skipping too many documents. I would like to avoid building an array of every quizz played by each player and find the next non-played in the database with a $nin. Thanks for your help

    Read the article

  • Maths Question: number of different permutations

    - by KingCong
    This is more of a maths question than programming but I figure a lot of people here are pretty good at maths! :) My question is: Given a 9 x 9 grid (81 cells) that must contain the numbers 1 to 9 each exactly 9 times, how many different grids can be produced. The order of the numbers doesn't matter, for example the first row could contain nine 1's etc. This is related to Sudoku and we know the number of valid Sudoku grids is 6.67×10^21, so since my problem isn't constrained like Sudoku by having to have each of the 9 numbers in each row, column and box then the answer should be greater than 6.67×10^21. My first thought was that the answer is 81! however on further reflection this assume that the 81 number possible for each cell are different, distinct number. They are not, there are 81 possible numbers for each cell but only 9 possible different numbers. My next thought was then that each of the cells in the first row can be any number between 1 and 9. If by chance the first row happened to be all the same number, say all 1s, then each cell in the second row could only have 8 possibilites, 2-9. If this continued down until the last row then number of different permutations could be calculated by 9^2 * 8^2 * 7^2 ..... * 1^2. However this doesn't work if each row doesn't contain 9 of the same number. It's been quite a while since I studied this stuff and I can't think of a way to work it out, I'd appreciate any help anyone can offer.

    Read the article

  • The Numerical ‘Magic’ of Cyclic Numbers

    - by Akemi Iwaya
    If you love crunching numbers or are just a fan of awesome number ‘tricks’ to impress your friends with, then you will definitely want to have a look at cyclic numbers. Dr Tony Padilla from the University of Nottingham shows how these awesome numbers work in Numberphile’s latest video. Cyclic Numbers – Numberphile [YouTube] Want to learn more about cyclic numbers? Then make sure to visit the Wikipedia page linked below! Cyclic number [Wikipedia]     

    Read the article

  • maths in Javascript.

    - by Jared
    Can someone please help me out with a javascript/jquery solution for this arithmetic problem... I need to subtract one number from the other. The problem is that the numbers have dollar signs (because its money). So it seems that jquery is treating them as strings instead of numbers. I have created two variables - toalAssets and totalLiabilites. I would like to subtract the latter from the former and place the result into another variable called netWorth Perhaps i need to use 'parseFloat'? But I'm not sure how - his is all a little over my head!

    Read the article

  • Faut-il être bon en math pour être un bon développeur ? Quelle place ont les maths dans votre parcou

    Faut-il être bon en math pour être un bon développeur ? Quelle place ont les maths dans votre métier et votre parcours ? Faut-il être bon en math pour être un bon développeur ? La question mérite d'être posée. Certes, l'informatique est à classer, dans le système universitaire, du coté des sciences "dures", par oppositions aux sciences sociales et humaines. L'enseignement des mathématiques et la rigueur qu'elles amènent paraissent donc indispensable. Pourtant, beaucoup, comme Alan Skorkin - qui vient d'aborder ce sujet sur son blog -, reconnaissent qu'ils n'ont jamais vraiment eu besoin des maths dans leur travail. La position de Alan Skorkin est c...

    Read the article

  • Maths: Determining angle in 3D space

    - by 742
    I hope this is the proper location to ask this question which is the same as this one, but expressed as pure math instead of graphically (at least I hope I translated the problem to math correctly). Considering: two vectors that are orthogonal: Up (ux, uy, uz) and Look (lx, ly, lz) a plane P which is perpendicular to Look (hence including Up) Y1 which is the projection of Y (vertical axis) along Look onto P Question: what is the value of the angle between Y1 and Up? As mathematicians will agree, this is a very basic question, but I've been scratching my head on walls now for at least two weeks without being able to visualize the solution... maybe now too old for finding solutions to school exercises. I'm looking for the scalar trigonometric solution, not a solution using a matrix. Thanks.

    Read the article

  • How can you calculate the X/Y coordinate to zoom to

    - by Mark
    Im writing a WPF application that has a zoom and pan ability, but what I want to also implement is the ability to zoom and pan "automatically" (via a button click). I have the methods all defined to zoom and pan, but Im having trouble telling the app the desired X/Y coordinates for the panning. Basically, I know that I want the control to be centered at a desired zoom level (say zoomed in 6X times), but the panning destination point is NOT the center point of the control because after the zooming, its been scaled. Does anyone know a way of calculating the desired X/Y position to pan to, taking into account the zooming as well? Do I just scale the desired destination Point? It doesnt seem to work for me... Thanks a lot

    Read the article

  • How to know coordinates in a real image from a scaled image.

    - by ocell
    Hi folks, First of all thanks for your time reading my question :-) I have an original image (w': 2124, h': 3204) and the same image scaled (w: 512, h: 768). The ratio for width is 4.14 (rw) and the ratio for height is 4.17 (rh). I'm trying to know the coordinates (x', y') in the original image when I receive the coordinates in the scaled image (x, y). I'm using the formula: x' = x * rw and y' = y * rh. But when I'm painting a line, or a rectangle always appears a shift that is incremented when x or y is higher. Please anybody knows how to transform coordinates without loosing of accuracy. Thanks in advance! Oscar.

    Read the article

  • Scaling ratio of two different resolutions

    - by BBDeveloper
    I have two different resolutions, the original one is 567x756 (wXh), the one which I want to display is 768x1024 (wXh). How to find out the scaling ratio for these two resolutions? For example if the font size used in 567x756 resolution is 7 pts then whats the values I should multiply with the font size (7 pts) to display the text in 768x1024 resolution. Can anyone help me in this issue? Its little urgent. Thanks in advance.

    Read the article

  • What are the maths behind 'Raiden 2' purple laser?

    - by Aybe
    The path of the laser is affected by user input and enemies present on the screen. Here is a video, at 5:00 minutes the laser in question is shown : Raiden II (PS) - 1 Loop Clear - Part 2 UPDATE Here is a test using Inkscape, ship is at bottom, the first 4 enemies are targeted by the plasma. There seems to be a sort of pattern. I moved the ship first, then the handle from it to form a 45° angle, then while trying to fit the curve I found a pattern of parallel handles and continued so until I reached the last enemy. Update, 5/26/2012 : I started an XNA project using beziers, there is still some work needed, will update the question next week. Stay tuned ! Update : 5/30/2012 : It really seems that they are using Bézier curves, I think I will be able to replicate/imitate a plasma of such grade. There are two new topics I discovered since last time : Arc length, Runge's phenomenon, first one should help in having a linear movement possible over a Bézier curve, second should help in optimizing the number of vertices. Next time I will put a video so you can see the progress 8-)

    Read the article

1 2 3 4 5 6 7 8  | Next Page >