Search Results

Search found 313 results on 13 pages for 'mathematics'.

Page 3/13 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Using Bullet physics engine to find the moment of object contact before penetration

    - by MooMoo
    I would like to use Bullet Physics engine to simulate the objects in 3D world. One of the objects in the world will move using the position from 3D mouse control. I will call it "Mouse Object" and any object in the world as "Object A" I define the time before "mouse object" and "Object A" collide as t-1 The time "mouse object" penetrate "Object A" as t Now there is a problem about rendering the scene because when I move the mouse very fast, "Mouse object" will reside in "Object A" before "Object A" start to move. I would like the "Mouse Object" to stop right away attach to the "Object A". Also If the "Object A" move, the "Mouse object" should move following (attach) the "Object A" without stop at the first collision take place. This is what i did I find the position of the "Mouse Object" at time t-1 and time t. I will name it as pos(t-1) and pos(t) The contact time will be sometime between t-1 to t, which the time of contact I name it as t_contact, therefore the contact position (without penetration) between "Mouse object" and "Object A" will be pos(t_contact) then I create multiple "Mouse object"s using this equation pos[n] = pos(t-1) * C * ( pos(t) - pos(t-1) ) where 0 <= C <= 1 if I choose C = 0.1, 0.2, 0.3,0.4..... 1.0, I will get pos[n] for 10 values Then I test collision for all of these 10 "Mouse Objects" and choose the one that seperate between "no collision" and "collision". I feel this method is super non-efficient. I am not sure the way other people find the time-of-contact or the position-of-contact when "Object A" can move.

    Read the article

  • Rotate 2d sprite towards pointer

    - by Phil
    I'm using Crafty.js and am trying to point a sprite towards the mouse pointer. I have a function for getting the degree between two points and I'm pretty sure it works mathematically (I have it under unit tests). At least it responds that the degree between { 0,0} and {1,1} is 45, which seems right. However, when I set the sprite rotation to the returned degree, it's just wrong all the time. If I manually set it to 90, 45, etc, it gets the right direction.. I have a jsfiddle that shows what I've done so far. Any ideas?

    Read the article

  • 2d array permutation proof [migrated]

    - by FGM
    I want to know if it's possible to get any possible combination of a 4x4 integer array given three rules: you may shift any column up or down you may shift any row left or right you may shift the entire array left, right, up, or down That is, you can transform: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] into any possible combination of a 4x4 array of the same 16 values, given those three rules. Basically, I just want to know if there are impossible combinations.

    Read the article

  • Transforms in Box2D

    - by user1264811
    I'm attempting to implement a camera in my game. I had it working for regular objects, but I began using Box2D and obviously things changed a bit. I have a Body object that I want to draw at the center of the screen. Basically what I'm doing is subtracting the viewportX and viewportY to the Body. I use this code that currently is not working as it should: public void paint(Graphics2D g, int viewportX, int viewportY) { Transform xf = new Transform(); // m_body is the Body object xf.set(m_body.getTransform()); // Here what I attemp to do is take the transform and alter it // by the viewportX and Y, which is something like **-240, -150**. // Why is it negative? Because an object has coordinates 500, 300 would be displayed // at 160, 150 when the subtraction is done. // With the DrawUtils.toScale(), it's just how I convert the units from JBox2D units // to my units. Vec2 v = Transform.mulTrans(xf, new Vec2(DrawUtils.toScale(-viewportX), DrawUtils.toScale(-viewportY))); // Set the new transform to the new vector. Keep the old angle. xf.set(v, xf.q.getAngle()); g.setColor(Color.white); // I know for a fact that the following method works 100%. It correctly displays // my object, just that it doesn't follow it. for (Fixture f = m_body.getFixtureList(); f != null; f = f.getNext()) DrawUtils.drawShape(f, xf); } Hopefully I didn't over comment this and you understand my problem. I don't want to alter the actual physics position of the object, I just want to display it in the center.

    Read the article

  • How do I convert screen coordinates to between -1 and 1?

    - by bbdude95
    I'm writing a function that allows me to click on my tiles. The origin for my tiles is the center, however, the mouse's origin is the top left. I need a way to transform my mouse coordinates into my tile coordinates. Here is what I already have (but is not working): void mouseClick(int button, int state, int x, int y) { x -= 400; y -= 300; float xx = x / 100; // This gets me close but the number is still high. float yy = y / 100; // It needs to be between -1 and 1 }

    Read the article

  • Optimizing mathematics on arrays of floats in Ada 95 with GNATC

    - by mat_geek
    Consider the bellow code. This code is supposed to be processing data at a fixed rate, in one second batches, It is part of an overal system and can't take up too much time. When running over 100 lots of 1 seconds worth of data the program takes 35 seconds; or 35%. How do I improce the code to get the processing time down to a minimum? The code will be running on an Intel Pentium-M which is a P3 with SSE2. package FF is new Ada.Numerics.Generic_Elementary_Functions(Float); N : constant Integer := 820; type A is array(1 .. N) of Float; type A3 is array(1 .. 3) of A; procedure F(state : in out A3; result : out A3; l : in A; r : in A) is s : Float; t : Float; begin for i in 1 .. N loop t := l(i) + r(i); t := t / 2.0; state(1)(i) := t; state(2)(i) := t * 0.25 + state(2)(i) * 0.75; state(3)(i) := t * 1.0 /64.0 + state(2)(i) * 63.0 /64.0; for r in 1 .. 3 loop s := state(r)(i); t := FF."**"(s, 6.0) + 14.0; if t > MAX then t := MAX; elsif t < MIN then t := MIN; end if; result(r)(i) := FF.Log(t, 2.0); end loop; end loop; end;

    Read the article

  • Using OpenGL Mathematics (GLM) in an Objective-C program

    - by user1621592
    i am trying to use GLM to load a .obj object in my Objective-C Program (Xcode 4.4 Mac Os X). I have added the glm folder to my project. i try to import it using #import "glm/glm.hpp", but the program doesn't build. some of the errors are the following: (this errors are produced in the GLM files) namespace glm{ //Unknown type name 'namespace' namespace detail { ..... it doesn't find the cstdlib, cmath, and other libraries.... This happens because my program is in Objective-c and the GLM doesn't work with this language??? How can i resolve this problem??? Thanks for your help.

    Read the article

  • Optimizing mathematics on arrays of floats in Ada 95 with GNAT

    - by mat_geek
    Consider the bellow code. This code is supposed to be processing data at a fixed rate, in one second batches, It is part of an overal system and can't take up too much time. When running over 100 lots of 1 seconds worth of data the program takes 35 seconds (or 35%), executing this function in a loop. The test loop is timed specifically with Ada.RealTime. The data is pregenerated so the majority of the execution time is definatetly in this loop. How do I improce the code to get the processing time down to a minimum? The code will be running on an Intel Pentium-M which is a P3 with SSE2. package FF is new Ada.Numerics.Generic_Elementary_Functions(Float); N : constant Integer := 820; type A is array(1 .. N) of Float; type A3 is array(1 .. 3) of A; procedure F(state : in out A3; result : out A3; l : in A; r : in A) is s : Float; t : Float; begin for i in 1 .. N loop t := l(i) + r(i); t := t / 2.0; state(1)(i) := t; state(2)(i) := t * 0.25 + state(2)(i) * 0.75; state(3)(i) := t * 1.0 /64.0 + state(2)(i) * 63.0 /64.0; for r in 1 .. 3 loop s := state(r)(i); t := FF."**"(s, 6.0) + 14.0; if t > MAX then t := MAX; elsif t < MIN then t := MIN; end if; result(r)(i) := FF.Log(t, 2.0); end loop; end loop; end; psuedocode for testing create two arrays of 80 random A3 arrays, called ls and rs; init the state and result A3 array record the realtime time now, called last for i in 1 .. 100 loop for j in 1 .. 80 loop F(state, result, ls(j), rs(j)); end loop; end loop; record the realtime time now, called curr output the duration between curr and last

    Read the article

  • hi question about mathematics

    - by davit-datuashvili
    hi i have one question i know site mathoverflow.com and have posted question but unfortunately no one give me answer if i post here can anybody help me? it is not homework because i know somebody will say it is homework what u have tried but this is not so i dont know how solve please if it is possible i will post here ok?

    Read the article

  • The mathematics of Schellings segregation model

    - by Bruce
    For those who don't know the model. You can read this pdf. I want to find what is the probability that 2 nodes are each others neighbors when the algorithm converges (i.e. when all nodes are happy). Here's the model in a gist. You have a grid (say 10x10). You have nodes of two kind (red and green) 45 each. So we have 10 empty spaces. We randomly place the nodes on the grid. Now we scan through this grid (Exact order does not matter according to Schelling). Each node wants a specific percentage of people of same kind in its Moore neighborhood (say b = 50% for each red and green). We calculate the happiness of each node (a = Number of neighbors of same kind/Number of neighbors of different kind). If a node is unhappy (a < b) it moves to an empty cell where it knows it will be happy. This movement can change the dynamics of old as well as new neighborhood. Algorithm converges when all nodes are happy. PS - I am looking for links for any mathematical analysis of the Schelling's model.

    Read the article

  • Mathematics errors in basic C++ program

    - by H Bomb1013
    I am working with a basic C++ program to determine the area and perimeter of a rectangle. My program works fine for whole numbers but falls apart when I use any number with a decimal. I get the impression that I am leaving something out, but since I'm a complete beginner, I have no idea what. Below is the source: #include <iostream> using namespace std; int main() { // Declared variables int length; // declares variable for length int width; // declares variable for width int area; // declares variable for area int perimeter; // declares variable for perimeter // Statements cout << "Enter the length and the width of the rectangle: "; // states what information to enter cin >> length >> width; // user input of length and width cout << endl; // closes the input area = length * width; // calculates area of rectangle perimeter = 2 * (length + width); //calculates perimeter of rectangle cout << "The area of the rectangle = " << area << " square units." <<endl; // displays the calculation of the area cout << "The perimeter of the rectangle = " << perimeter << " units." << endl; // displays the calculation of the perimeter system ("pause"); // REMOVE BEFORE RELEASE - testing purposes only return 0; }

    Read the article

  • Mathematics and Game Programming

    - by Xfcn
    I want to program graphical 2D games more complex than the basic 2D stuff I already know. I don't want to do 3D programming. Just more complex 2D stuff. I dropped high school before I could learn a lot of stuff so I walked away with enough algebra knowledge to balance my checkbook and do some light 2D Cartesian programming. Are there any good resources out there for a guy with a limited attention span (say 20 minutes apiece for a subject I'm keenly interested in) to learn, gradually, how to do something more useful with math in programming?

    Read the article

  • How important is Discrete Mathematics for a Computer Scientist?

    - by mort
    As the title says, How important is Discrete Mathematics for a Computer Scientist? Background: I'm pursuing a Master's degree with a focus on fundamentals such as Algorithms, Complexity and Computability Theory and Programming Languages to get a good foundation for working in the field of Parallel Computing. Some more background: My university grants a lot of freedom in the choices of courses for my Master's degree. It's officially called "Software Engineering", but due to a the broad range of electives, a different focus is possible. Interestingly, none of the electives is a lecture in Math! I'm thinking about doing a course about Discrete Mathematics that would take half a semester to complete successfully, even if I can't use it for my degree. So with this question I'm trying to find out if the effort is justifiable.

    Read the article

  • Is there really such a thing as "being good at math"?

    - by thezhaba
    Aside from gifted individuals able to perform complex calculations in their head, I'm wondering if proficiency in mathematics, namely calculus and algebra, has really got to do with one's natural inclination towards sciences, if you can put it that way. A number of students in my calculus course pick up material in seemingly no time whereas I, personally, have to spend time thinking about and understanding most concepts. Even then, if a question that requires a bit more 'imagination' comes up I don't always recognize the concepts behind it, as is the case with calculus proofs, for instance. Nevertheless, I refuse to believe that I'm simply not made for it. I do very well in programming and software engineering courses where a lot of students struggle. At first I could not grasp what they found to be so difficult, but eventually I realized that having previous programming experience is a great asset -- once I've seen and made practical use of the programming concepts learning about them in depth in an academic setting became much easier as I have then already seen their use "in the wild". I suppose I'm hoping that something similar happens with mathematics -- perhaps once the practical idea behind a concept (which authors of textbooks sure do a great job of concealing..) is evident, understanding the seemingly dry and symbolic ideas and proofs would be more obvious? I'm really not sure. All I'm sure of is I'd like to get better at calculus, but I don't yet understand why some of us pick it up easily while others have to spend considerable amounts of time on it and still not have complete understanding if an unusual problem is given.

    Read the article

  • why do we need advanced knowledge of mathematics & physics for programming?

    - by Sumeet
    Guys, I have been very good in mathematics and physics in my schools and colleges. Right now I am a programmer. Even in the colleges I have to engrossed my self into computers and programming things all the time. As I used to like it very much. But I have always felt the lack of advanced mathematics and physics in all the work I have done (Programs). Programming never asked me any advanced mathematics and physics knowledge in what I was very good. It always ask u some optimized loops, and different programming technologies which has never been covered in advanced mathematics and physics. Even at the time of selection in big College , such a kind of advanced knowledge is required. Time by time I got out of touch of all that facts and concepts (advanced mathematics and physics). And now after, 5 years in job I found it hard to resolve Differentiations and integrations from Trigonometry. Which sometimes make me feel like I have wasted time in those concepts because they are never used. (At that time I knew that I am going to be a programmer) If one need to be a programmer why do all this advanced knowledge is required. One can go with elementry knowledge a bit more. You never got to think like scientists and R&D person in your Schols and colleges for being a programmer? Just think and let me know your thoughts. I must be wrong somewhere in what I think , but not able to figure that out..? Regards Sumeet

    Read the article

  • Neural Network 0 vs -1

    - by Louis
    I have seen a few times people using -1 as opposed to 0 when working with neural networks for the input data. How is this better and does it effect any of the mathematics to implement it? Edit: Using feedforward and back prop Edit 2: I gave it a go but the network stopped learning so I assume the maths would have to change somewhere?

    Read the article

  • How to calculate the cycles that change one permutation into another?

    - by fortran
    Hi, I'm looking for an algorithm that given two permutations of a sequence (e.g. [2, 3, 1, 4] and [4, 1, 3, 2]) calculates the cycles that are needed to convert the first into the second (for the example, [[0, 3], [1, 2]]). The link from mathworld says that Mathematica's ToCycle function does that, but sadly I don't have any Mathematica license at hand... I'd gladly receive any pointer to an implementation of the algorithm in any FOSS language or mathematics package. Thanks!

    Read the article

  • Better algorithm for estimating download time

    - by Scott Smith
    We've all seen the download time running estimate that initially says something like "7 days", but keeps dropping wildly (e.g. "23 hours", "45 minutes", "1 min. 50 sec", etc) with each successive estimation as the chunks are downloaded. To avoid these initial (alarming) estimates, there are techniques one could try like suppressing display of the first n estimates, or waiting for the delta between estimates to drop below some threshold before you start displaying them, but these don't seem like a general, robust solution. There are corner cases involving too few samples, or samples that actually are wildly varying... I think I recall a general solution for this kind of thing in mathematics (statistics?) that reduced or eliminated these wild values. Does anyone know?

    Read the article

  • Should I Teach My Son Programming? What approaches should I take? [closed]

    - by DaveDev
    I was wondering if it's a good idea to teach object oriented programming to my son? I was never really good at math as a kid, but I think since I've started programming it's given me a greater ability to understand math by being better able to visualise relationships between abstract models. I thought it might give him a better advantage in learning & applying logical & mathematical concepts throughout his life if he was able to take advantage of the tools available to programmers. what would be the best programming fields, techniques and/or concepts? What approach should I take? what concepts should I avoid? what fields of mathematics would he find this benfits him most? He's only 2 now so it wouldn't be for another few years before I do this, (and even at that, only from a very high level point of view). I thought I'd put it to the programming community and see what you guys thought? Possible Duplicate: What are some recommended programming resources for pre-teens?

    Read the article

  • Runge-Kutta (RK4) integration for game physics

    - by Kai
    Gaffer on Games has a great article about using RK4 integration for better game physics. The implementation is straightforward but the math behind it confuses me. I understand derivatives and integrals on a conceptual level but I haven't manipulated equations in a long time. Here's the brunt of Gaffer's implementation: void integrate(State &state, float t, float dt) { Derivative a = evaluate(state, t, 0.0f, Derivative()); Derivative b = evaluate(state, t+dt*0.5f, dt*0.5f, a); Derivative c = evaluate(state, t+dt*0.5f, dt*0.5f, b); Derivative d = evaluate(state, t+dt, dt, c); const float dxdt = 1.0f/6.0f * (a.dx + 2.0f*(b.dx + c.dx) + d.dx); const float dvdt = 1.0f/6.0f * (a.dv + 2.0f*(b.dv + c.dv) + d.dv) state.x = state.x + dxdt * dt; state.v = state.v + dvdt * dt; } Can anybody explain in simple terms how RK4 works? Specifically, why are we averaging the derivatives at 0.0f, 0.5f, 0.5f, and 1.0f? How is averaging derivatives up to the 4th order different from doing a simple euler integration with a smaller timestep? After reading the accepted answer below, and several other articles, I have a grasp on how RK4 works. To answer my own questions: Can anybody explain in simple terms how RK4 works? RK4 takes advantage of the fact that we can get a much better approximation of a function if we use its higher-order derivatives rather than just the first or second derivative. That's why the Taylor series converges much faster than Euler approximations. (take a look at the animation on the right side of that page) Specifically, why are we averaging the derivatives at 0.0f, 0.5f, 0.5f, and 1.0f? The Runge-Kutta method is an approximation of a function that samples derivatives of several points within a timestep, unlike the Taylor series which only samples derivatives of a single point. After sampling these derivatives we need to know how to weigh each sample to get the closest approximation possible. An easy way to do this is to pick constants that coincide with the Taylor series, which is how the constants of a Runge-Kutta equation are determined. This article made it clearer for me: http://web.mit.edu/10.001/Web/Course%5FNotes/Differential%5FEquations%5FNotes/node5.html. Notice how (15) is the Taylor series expansion while (17) is the Runge-Kutta derivation. How is averaging derivatives up to the 4th order different from doing a simple euler integration with a smaller timestep? Mathematically it converges much faster than doing many Euler approximations. Of course, with enough Euler approximations we can gain equal accuracy to RK4, but the computational power needed doesn't justify using Euler.

    Read the article

  • Find the "largest" dense sub matrix in a large sparse matrix

    - by BCS
    Given a large sparse matrix (say 10k+ by 1M+) I need to find a subset, not necessarily continuous, of the rows and columns that form a dense matrix (all non-zero elements). I want this sub matrix to be as large as possible (not the largest sum, but the largest number of elements) within some aspect ratio constraints. Are there any known exact or aproxamate solutions to this problem? A quick scan on Google seems to give a lot of close-but-not-exactly results. What terms should I be looking for? edit: Just to clarify; the sub matrix need not be continuous. In fact the row and column order is completely arbitrary so adjacency is completely irrelevant. A thought based on Chad Okere's idea Order the rows from largest count to smallest count (not necessary but might help perf) Select two rows that have a "large" overlap Add all other rows that won't reduce the overlap Record that set Add whatever row reduces the overlap by the least Repeat at #3 until the result gets to small Start over at #2 with a different starting pair Continue until you decide the result is good enough

    Read the article

  • How would you solve this graph theory handshake problem in python?

    - by Zachary Burt
    I graduated college last year with a degree in Psychology, but I also took a lot of math for fun. I recently got the book "Introductory Graph Theory" by Gary Chartrand to brush up on my math and have some fun. Here is an exercise from the book that I'm finding particularly befuddling: Suppose you and your husband attended a party with three other married couples. Several handshakes took place. No one shook hands with himself (or herself) or with his (or her) spouse, and no one shook hands with the same person more than once. After all the handshaking was completed, suppose you asked each person, including your husband, how many hands he or she had shaken. Each person gave a different answer. a) How many hands did you shake? b) How many hands did your husband shake? Now, I've been reasoning about this for a while, and trying to draw sample graphs that could illustrate a solution, but I'm coming up empty-handed. My logic is this: there are 8 different vertices in the graph, and 7 of them have different degrees. The values for the degrees must therefore be 0, 1, 2, 3, 4, 5, 6, and x. The # of degrees for one married couple is (0, 6). Since all graphs have an even number of odd vertices, x must be either 5, 3, or 1. What's your solution to this problem? And, if you could solve it in python, how would you do it? (python is fun.) Cheers.

    Read the article

  • How would you solve this graph theory handshake problem in python?

    - by Zachary Burt
    I graduated college last year with a degree in Psychology, but I also took a lot of math for fun. I recently got the book "Introductory Graph Theory" by Gary Chartrand to brush up on my math and have some fun. Here is an exercise from the book that I'm finding particularly befuddling: Suppose you and your husband attended a party with three other married couples. Several handshakes took place. No one shook hands with himself (or herself) or with his (or her) spouse, and no one shook hands with the same person more than once. After all the handshaking was completed, suppose you asked each person, including your husband, how many hands he or she had shaken. Each person gave a different answer. a) How many hands did you shake? b) How many hands did your husband shake? Now, I've been reasoning about this for a while, and trying to draw sample graphs that could illustrate a solution, but I'm coming up empty-handed. My logic is this: there are 8 different vertices in the graph, and 7 of them have different degrees. The values for the degrees must therefore be 0, 1, 2, 3, 4, 5, 6, and x. The # of degrees for one married couple is (0, 6). Since all graphs have an even number of odd vertices, x must be either 5, 3, or 1. What's your solution to this problem? And, if you could solve it in python, how would you do it? (python is fun.) Cheers.

    Read the article

  • naive bayesian spam filter question

    - by Microkernel
    Hi guys, I am planning to implement spam filter using Naive Bayesian classification model. Online I see a lot of info on Naive Bayesian classification, but the problem is its a lot of mathematical stuff, than clearly stating how its done. And the problem is I am more of a programmer than a mathematician (yes I had learnt Probability and Bayesian theorem back in school, but out of touch for a long long time, and I don't have luxury of learning it now (Have nearly 3 weeks to come-up with a working prototype)). So if someone can explain or point me to location where its explained for programmers than a mathematician, it would be a great help. PS: By the way I have to implement it in C, if you want to know. :( Regards, Microkernel

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >