Search Results

Search found 3425 results on 137 pages for 'polynomial math'.

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

  • polynomial multiplication using fastfourier transform

    - by mawia
    i am going through the above topic from CLRS(CORMEN) (page 834) and I got stuck at this point. Can anybody please explain how the following expression, A(x)=A^{[0]}(x^2) +xA^{[1]}(x^2) follows from, n-1 ` S a_j x^j j=0 Where, A^{[0]} = a_0 + a_2x + a_4a^x ... a_{n-2}x^{\frac{n}{2-1}} A^{[1]} = a_1 + a_3x + a_5a^x ... a_{n-1}x^{\frac{n}{2-1}} WITH REGARDS THANKS

    Read the article

  • Fixed point math in c#?

    - by x4000
    Hi there, I was wondering if anyone here knows of any good resources for fixed point math in c#? I've seen things like this (http://2ddev.72dpiarmy.com/viewtopic.php?id=156) and this (http://stackoverflow.com/questions/79677/whats-the-best-way-to-do-fixed-point-math), and a number of discussions about whether decimal is really fixed point or actually floating point (update: responders have confirmed that it's definitely floating point), but I haven't seen a solid C# library for things like calculating cosine and sine. My needs are simple -- I need the basic operators, plus cosine, sine, arctan2, PI... I think that's about it. Maybe sqrt. I'm programming a 2D RTS game, which I have largely working, but the unit movement when using floating-point math (doubles) has very small inaccuracies over time (10-30 minutes) across multiple machines, leading to desyncs. This is presently only between a 32 bit OS and a 64 bit OS, all the 32 bit machines seem to stay in sync without issue, which is what makes me think this is a floating point issue. I was aware from this as a possible issue from the outset, and so have limited my use of non-integer position math as much as possible, but for smooth diagonal movement at varying speeds I'm calculating the angle between points in radians, then getting the x and y components of movement with sin and cos. That's the main issue. I'm also doing some calculations for line segment intersections, line-circle intersections, circle-rect intersections, etc, that also probably need to move from floating-point to fixed-point to avoid cross-machine issues. If there's something open source in Java or VB or another comparable language, I could probably convert the code for my uses. The main priority for me is accuracy, although I'd like as little speed loss over present performance as possible. This whole fixed point math thing is very new to me, and I'm surprised by how little practical information on it there is on google -- most stuff seems to be either theory or dense C++ header files. Anything you could do to point me in the right direction is much appreciated; if I can get this working, I plan to open-source the math functions I put together so that there will be a resource for other C# programmers out there. UPDATE: I could definitely make a cosine/sine lookup table work for my purposes, but I don't think that would work for arctan2, since I'd need to generate a table with about 64,000x64,000 entries (yikes). If you know any programmatic explanations of efficient ways to calculate things like arctan2, that would be awesome. My math background is all right, but the advanced formulas and traditional math notation are very difficult for me to translate into code.

    Read the article

  • Recommended Math textbooks for programmers

    - by Tony
    I learned math in a non-English environment, I recently read some books about algorithm analysis, I found some math concepts were confusing, and seemed not the same as what I've learned. What math textbooks would you recommend that covers math concepts from the scratch and suitable for self-learning ?

    Read the article

  • Best software for taking math notes at lectures

    - by data_jepp
    Let me first just say that I know about La-Tex, and that doesn't fast enough. I use it for papers, but for "real-time" note taking it's just to heavy. I'm talking two math classes this semester. Linear algebra and discrete math, I just got a laptop with 10 hour battery life which makes me want to take notes on it!!! Openoffice with formula thingy is what I use now. Now I have to pay attention lol. Thanks.

    Read the article

  • Performance of Java matrix math libraries?

    - by dfrankow
    We are computing something whose runtime is bound by matrix operations. (Some details below if interested.) This experience prompted the following question: Do folk have experience with the performance of Java libraries for matrix math (e.g., multiply, inverse, etc.)? For example: JAMA: http://math.nist.gov/javanumerics/jama/ COLT: http://acs.lbl.gov/~hoschek/colt/ Apache commons math: http://commons.apache.org/math/ I searched and found nothing. Details of our speed comparison: We are using Intel FORTRAN (ifort (IFORT) 10.1 20070913). We have reimplemented it in Java (1.6) using Apache commons math 1.2 matrix ops, and it agrees to all of its digits of accuracy. (We have reasons for wanting it in Java.) (Java doubles, Fortran real*8). Fortran: 6 minutes, Java 33 minutes, same machine. jvisualm profiling shows much time spent in RealMatrixImpl.{getEntry,isValidCoordinate} (which appear to be gone in unreleased Apache commons math 2.0, but 2.0 is no faster). Fortran is using Atlas BLAS routines (dpotrf, etc.). Obviously this could depend on our code in each language, but we believe most of the time is in equivalent matrix operations. In several other computations that do not involve libraries, Java has not been much slower, and sometimes much faster.

    Read the article

  • Entry Level Programming Jobs with Applied Math Degree

    - by Mark
    I am about to finish my B.Sc. in Applied Math. I started out in CS a few years back had a bit of a change of heart and decided to go the math route. Now that I am looking for career options finishing up and I'm just wonder how my Applied Math degree will look when applying for programming jobs. I have taken CS courses in C++/Java/C and done 2 semester of Scientific Computing with MATLAB/Mathematica and the like, so I feel like i at least know how to program. Of course I am lacking some of the theoretical courses on the CS. I'd very much like to know how I stack up for a programming job as a math major. Thanks.

    Read the article

  • Parsing basic math equations for children's educational software?

    - by Simucal
    Inspired by a recent TED talk, I want to write a small piece of educational software. The researcher created little miniature computers in the shape of blocks called "Siftables". [David Merril, inventor - with Siftables in the background.] There were many applications he used the blocks in but my favorite was when each block was a number or basic operation symbol. You could then re-arrange the blocks of numbers or operation symbols in a line, and it would display an answer on another siftable block. So, I've decided I wanted to implemented a software version of "Math Siftables" on a limited scale as my final project for a CS course I'm taking. What is the generally accepted way for parsing and interpreting a string of math expressions, and if they are valid, perform the operation? Is this a case where I should implement a full parser/lexer? I would imagine interpreting basic math expressions would be a semi-common problem in computer science so I'm looking for the right way to approach this. For example, if my Math Siftable blocks where arranged like: [1] [+] [2] This would be a valid sequence and I would perform the necessary operation to arrive at "3". However, if the child were to drag several operation blocks together such as: [2] [\] [\] [5] It would obviously be invalid. Ultimately, I want to be able to parse and interpret any number of chains of operations with the blocks that the user can drag together. Can anyone explain to me or point me to resources for parsing basic math expressions? I'd prefer as much of a language agnostic answer as possible.

    Read the article

  • Underbraces in Word math zones and dealing with stretchy parentheses

    - by Johannes Rössel
    Parentheses in Word usually stretch with whatever they're containing. This might be un-noticeable for things like but for stuff like it's definitely nice, especially compared to the fact that naïve LaTeX users often produce uglinesses such as There is a problem, however, when using under-/overbraces in math and putting parentheses around the complete term it becomes ugly. For simple things like shown here this can be solved by not letting the parentheses stretch which looks almost right. However, for more complex things it's certainly not an option: Both variants look horrible. So is there a way of letting the parentheses only stretch around the actual term parts, not including the under-/overbraces? Those are frequently used for annotations of individual pieces, so simply not using them is a bad idea too. In LaTeX you can get away with guesswork and using explicit sizes for the parentheses instead of relying on \left and \right but I haven't found a comparable option in Word yet. Since the underbrace is (tree-wise) a sibling of the term in parentheses it probably simply has to stretch and there probably can't be an algorithm that determines when to stretch or when not, considering that \above and \below are used for annotations as well but also for other things where perentheses have to stretch. Also, since the parenthesized expression is opaque from the outside one has to put the underbrace inside. From a markup point of view, at least. One can probably draw the rest around but that falls apart when styles change and wouldn't be a good idea either.

    Read the article

  • Underbraces in Word math zones and dealing with parentheses

    - by Johannes Rössel
    Parentheses in Word usually stretch with whatever they're containing. This might be un-noticeable for things like but for stuff like it's definitely nice, especially compared to the fact that naïve LaTeX users often produce uglinesses such as There is a problem, however, when using under-/overbraces in math and putting parentheses around the complete term it becomes ugly. For simple things like shown here this can be solved by not letting the parentheses stretch which looks almost right. However, for more complex things it's certainly not an option: Both variants look horrible. So is there a way of letting the parentheses only stretch around the actual term parts, not including the under-/overbraces? Those are frequently used for annotations of individual pieces, so simply not using them is a bad idea too. In LaTeX you can get away with guesswork and using explicit sizes for the parentheses instead of relying on \left and \right but I haven't found a comparable option in Word yet. Since the underbrace is (tree-wise) a sibling of the term in parentheses it probably simply has to stretch and there probably can't be an algorithm that determines when to stretch or when not, considering that \above and \below are used for annotations as well but also for other things where perentheses have to stretch. Also, since the parenthesized expression is opaque from the outside one has to put the underbrace inside. From a markup point of view, at least. One can probably draw the rest around but that falls apart when styles change and wouldn't be a good idea either.

    Read the article

  • Math.max and Math.min outputting highest and lowest values allowed

    - by user1696162
    so I'm trying to make a program that will output the sum, average, and smallest and largest values. I have everything basically figured out except the smallest and largest values are outputting 2147483647 and -2147483647, which I believe are the absolute smallest and largest values that Java will compute. Anyway, I want to compute the numbers that a user enters, so this obviously isn't correct. Here is my class. I assume something is going wrong in the addValue method. public class DataSet { private int sum; private int count; private int largest; private int smallest; private double average; public DataSet() { sum = 0; count = 0; largest = Integer.MAX_VALUE; smallest = Integer.MIN_VALUE; average = 0; } public void addValue(int x) { count++; sum = sum + x; largest = Math.max(x, largest); smallest = Math.min(x, smallest); } public int getSum() { return sum; } public double getAverage() { average = sum / count; return average; } public int getCount() { return count; } public int getLargest() { return largest; } public int getSmallest() { return smallest; } } And here is my tester class for this project: public class DataSetTester { public static void main(String[] arg) { DataSet ds = new DataSet(); ds.addValue(13); ds.addValue(-2); ds.addValue(3); ds.addValue(0); System.out.println("Count: " + ds.getCount()); System.out.println("Sum: " + ds.getSum()); System.out.println("Average: " + ds.getAverage()); System.out.println("Smallest: " + ds.getSmallest()); System.out.println("Largest: " + ds.getLargest()); } } Everything outputs correctly (count, sum, average) except the smallest and largest numbers. If anyone could point me in the right direction of what I'm doing wrong, that would be great. Thanks.

    Read the article

  • Android-Java: Constructing a triangle based on Coordinates on a map and your bearing

    - by Aidan
    Hi Guys, I'm constructing a geolocation based application and I'm trying to figure out a way to make my application realise when a user is facing the direction of the given location (a particular long / lat co-ord). I've got the math figured, I just have the triangle to construct. //UPDATE So I've figured out a good bit of this... Below is a method which takes in a long / lat value and attempts to compute a triangle finding a point 700 meters away and one to its left + right. It'd then use these to construct the triangle. It computes the correct longitude but the latitude ends up somewhere off the coast of east Africa. (I'm in Ireland!). public void drawtri(double currlng,double currlat, double bearing){ bearing = (bearing < 0 ? -bearing : bearing); System.out.println("RUNNING THE DRAW TRIANGLE METHOD!!!!!"); System.out.println("CURRENT LNG" + currlng); System.out.println("CURRENT LAT" + currlat); System.out.println("CURRENT BEARING" + bearing); //Find point X(x,y) double distance = 0.7; //700 meters. double R = 6371.0; //The radius of the earth. //Finding X's y value. Math.toRadians(currlng); Math.toRadians(currlat); Math.toRadians(bearing); distance = distance/R; Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+ Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing)); System.out.println("CURRENT ALAT!!: " + Global.Alat); //Finding X's x value. Global.Alng = currlng + Math.atan2(Math.sin(bearing)*Math.sin(distance) *Math.cos(currlat), Math.cos(distance)-Math.sin(currlat)*Math.sin(Global.Alat)); Math.toDegrees(Global.Alat); Math.toDegrees(Global.Alng); //Co-ord of Point B(x,y) // Note: Lng = X axis, Lat = Y axis. Global.Blat = Global.Alat+ 00.007931; Global.Blng = Global.Alng; //Co-ord of Point C(x,y) Global.Clat = Global.Alat - 00.007931; Global.Clng = Global.Alng; } From debugging I've determined the problem lies with the computation of the latitude done here.. Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+ Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing)); I have no idea why though and don't know how to fix it. I got the formula from this site.. http://www.movable-type.co.uk/scripts/latlong.html It appears correct and I've tested multiple things... I've tried converting to Radians then post computations back to degrees, etc. etc. Anyone got any ideas how to fix this method so that it will map the triangle ONLY 700 meters in from my current location in the direction that I am facing? Thanks, EDIT/// Converting the outcome to radians gives me a lat of 5.6xxxxxxxxxxxxxx .I have a feeling this bug has something to do with conversions but its not THAT simple. The equation is correct, it just.. outputs wrong..

    Read the article

  • Is Programming == Math?

    - by moffdub
    I've heard many times that all programming is really a subset of math. Some suggest that OO, at its roots, is mathematically based. I don't get the connection. Aside from some obvious examples: using induction to prove a recursive algorithm formal correctness proofs functional languages lambda calculus asymptotic complexity DFAs, NFAs, Turing Machines, and theoretical computation in general the fact that everything on the box is binary In what ways is programming really a subset of math? I'm looking for an explanation that might have relevance to enterprise/OO development (if there is a strong enough connection, that is). Thanks in advance. Edit: as I stated in a comment to an answer, math is uber important to programming, but what I struggle with is the "subset" argument.

    Read the article

  • Math Problem With Percentages

    - by TheDarkIn1978
    i'm terrible at math. trust me, you math experts will see why after reading my question. i have an object that is 300px in height. i need to calculate the percentage of that height where 90% = 300px (or the full height), 45% = 150px, 0% = 0px. so essentially, if i ask for 45% of the object's height, it will return 150px, or if i ask for 32% of the object's height, it will return __? i believe this is really basic math, so i apologize in advance.

    Read the article

  • What Math topics & resources to consider as beginner to indulge the book - Introduction to Algorithm

    - by sector7
    I'm a programmer who's beginning to appreciate the knowledge & usability of Algorithms in my work as I move forward with my skill-set. I don't want to take the short path by learning how to apply algorithms "as-is" but would rather like to know the foundation and fundamentals behind them. For that I need Math, at which I'm pretty "basic". I'm considering getting tuition's for that. What I would like is to have a concise syllabus/set of topics/book which I could hand over to my math tutor to get started. HIGHLY DESIRED: one book. the silver bullet. (fingers crossed!) PS: I've got some leads but want to hear you guys/gurus out: Discrete Math, Combinatorics, Graph theory, Calculus, Linear Algebra, and Number Theory. Looking forward to your answers. Thanks!

    Read the article

  • Finding the normal of OBB face with an OBB penetrating

    - by Milo
    Below is an illustration: I have an OBB in an OBB (see below for OBB2D code if needed). What I need to determine is, what face it is in, and what direction do I point the normal? The goal is to get the OBB out of the OBB so the normal needs to face outward of the OBB. How could I go about: Finding what face the line is penetrating given the 4 corners of the OBB and the class below: if we define dx=x2-x1 and dy=y2-y1, then the normals are (-dy, dx) and (dy, -dx). Which normal points outward of the OBB? Thanks public class OBB2D { // Corners of the box, where 0 is the lower left. private Vector2D corner[] = new Vector2D[4]; private Vector2D center = new Vector2D(); private Vector2D extents = new Vector2D(); private RectF boundingRect = new RectF(); private float angle; //Two edges of the box extended away from corner[0]. private Vector2D axis[] = new Vector2D[2]; private double origin[] = new double[2]; public OBB2D(Vector2D center, float w, float h, float angle) { set(center,w,h,angle); } public OBB2D(float left, float top, float width, float height) { set(new Vector2D(left + (width / 2), top + (height / 2)),width,height,0.0f); } public void set(Vector2D center,float w, float h,float angle) { Vector2D X = new Vector2D( (float)Math.cos(angle), (float)Math.sin(angle)); Vector2D Y = new Vector2D((float)-Math.sin(angle), (float)Math.cos(angle)); X = X.multiply( w / 2); Y = Y.multiply( h / 2); corner[0] = center.subtract(X).subtract(Y); corner[1] = center.add(X).subtract(Y); corner[2] = center.add(X).add(Y); corner[3] = center.subtract(X).add(Y); computeAxes(); extents.x = w / 2; extents.y = h / 2; computeDimensions(center,angle); } private void computeDimensions(Vector2D center,float angle) { this.center.x = center.x; this.center.y = center.y; this.angle = angle; boundingRect.left = Math.min(Math.min(corner[0].x, corner[3].x), Math.min(corner[1].x, corner[2].x)); boundingRect.top = Math.min(Math.min(corner[0].y, corner[1].y),Math.min(corner[2].y, corner[3].y)); boundingRect.right = Math.max(Math.max(corner[1].x, corner[2].x), Math.max(corner[0].x, corner[3].x)); boundingRect.bottom = Math.max(Math.max(corner[2].y, corner[3].y),Math.max(corner[0].y, corner[1].y)); } public void set(RectF rect) { set(new Vector2D(rect.centerX(),rect.centerY()),rect.width(),rect.height(),0.0f); } // Returns true if other overlaps one dimension of this. private boolean overlaps1Way(OBB2D other) { for (int a = 0; a < axis.length; ++a) { double t = other.corner[0].dot(axis[a]); // Find the extent of box 2 on axis a double tMin = t; double tMax = t; for (int c = 1; c < corner.length; ++c) { t = other.corner[c].dot(axis[a]); if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } } // We have to subtract off the origin // See if [tMin, tMax] intersects [0, 1] if ((tMin > 1 + origin[a]) || (tMax < origin[a])) { // There was no intersection along this dimension; // the boxes cannot possibly overlap. return false; } } // There was no dimension along which there is no intersection. // Therefore the boxes overlap. return true; } //Updates the axes after the corners move. Assumes the //corners actually form a rectangle. private void computeAxes() { axis[0] = corner[1].subtract(corner[0]); axis[1] = corner[3].subtract(corner[0]); // Make the length of each axis 1/edge length so we know any // dot product must be less than 1 to fall within the edge. for (int a = 0; a < axis.length; ++a) { axis[a] = axis[a].divide((axis[a].length() * axis[a].length())); origin[a] = corner[0].dot(axis[a]); } } public void moveTo(Vector2D center) { Vector2D centroid = (corner[0].add(corner[1]).add(corner[2]).add(corner[3])).divide(4.0f); Vector2D translation = center.subtract(centroid); for (int c = 0; c < 4; ++c) { corner[c] = corner[c].add(translation); } computeAxes(); computeDimensions(center,angle); } // Returns true if the intersection of the boxes is non-empty. public boolean overlaps(OBB2D other) { if(right() < other.left()) { return false; } if(bottom() < other.top()) { return false; } if(left() > other.right()) { return false; } if(top() > other.bottom()) { return false; } if(other.getAngle() == 0.0f && getAngle() == 0.0f) { return true; } return overlaps1Way(other) && other.overlaps1Way(this); } public Vector2D getCenter() { return center; } public float getWidth() { return extents.x * 2; } public float getHeight() { return extents.y * 2; } public void setAngle(float angle) { set(center,getWidth(),getHeight(),angle); } public float getAngle() { return angle; } public void setSize(float w,float h) { set(center,w,h,angle); } public float left() { return boundingRect.left; } public float right() { return boundingRect.right; } public float bottom() { return boundingRect.bottom; } public float top() { return boundingRect.top; } public RectF getBoundingRect() { return boundingRect; } public boolean overlaps(float left, float top, float right, float bottom) { if(right() < left) { return false; } if(bottom() < top) { return false; } if(left() > right) { return false; } if(top() > bottom) { return false; } return true; } };

    Read the article

  • Bouncing off a circular Boundary with multiple balls?

    - by Anarkie
    I am making a game like this : Yellow Smiley has to escape from red smileys, when yellow smiley hits the boundary game is over, when red smileys hit the boundary they should bounce back with the same angle they came, like shown below: Every 10 seconds a new red smiley comes in the big circle, when red smiley hits yellow, game is over, speed and starting angle of red smileys should be random. I control the yellow smiley with arrow keys. The biggest problem I have reflecting the red smileys from the boundary with the angle they came. I don't know how I can give a starting angle to a red smiley and bouncing it with the angle it came. I would be glad for any tips! My js source code : var canvas = document.getElementById("mycanvas"); var ctx = canvas.getContext("2d"); // Object containing some global Smiley properties. var SmileyApp = { radius: 15, xspeed: 0, yspeed: 0, xpos:200, // x-position of smiley ypos: 200 // y-position of smiley }; var SmileyRed = { radius: 15, xspeed: 0, yspeed: 0, xpos:350, // x-position of smiley ypos: 65 // y-position of smiley }; var SmileyReds = new Array(); for (var i=0; i<5; i++){ SmileyReds[i] = { radius: 15, xspeed: 0, yspeed: 0, xpos:350, // x-position of smiley ypos: 67 // y-position of smiley }; SmileyReds[i].xspeed = Math.floor((Math.random()*50)+1); SmileyReds[i].yspeed = Math.floor((Math.random()*50)+1); } function drawBigCircle() { var centerX = canvas.width / 2; var centerY = canvas.height / 2; var radiusBig = 300; ctx.beginPath(); ctx.arc(centerX, centerY, radiusBig, 0, 2 * Math.PI, false); // context.fillStyle = 'green'; // context.fill(); ctx.lineWidth = 5; // context.strokeStyle = '#003300'; // green ctx.stroke(); } function lineDistance( positionx, positiony ) { var xs = 0; var ys = 0; xs = positionx - 350; xs = xs * xs; ys = positiony - 350; ys = ys * ys; return Math.sqrt( xs + ys ); } function drawSmiley(x,y,r) { // outer border ctx.lineWidth = 3; ctx.beginPath(); ctx.arc(x,y,r, 0, 2*Math.PI); //red ctx.fillStyle="rgba(255,0,0, 0.5)"; ctx.fillStyle="rgba(255,255,0, 0.5)"; ctx.fill(); ctx.stroke(); // mouth ctx.beginPath(); ctx.moveTo(x+0.7*r, y); ctx.arc(x,y,0.7*r, 0, Math.PI, false); // eyes var reye = r/10; var f = 0.4; ctx.moveTo(x+f*r, y-f*r); ctx.arc(x+f*r-reye, y-f*r, reye, 0, 2*Math.PI); ctx.moveTo(x-f*r, y-f*r); ctx.arc(x-f*r+reye, y-f*r, reye, -Math.PI, Math.PI); // nose ctx.moveTo(x,y); ctx.lineTo(x, y-r/2); ctx.lineWidth = 1; ctx.stroke(); } function drawSmileyRed(x,y,r) { // outer border ctx.lineWidth = 3; ctx.beginPath(); ctx.arc(x,y,r, 0, 2*Math.PI); //red ctx.fillStyle="rgba(255,0,0, 0.5)"; //yellow ctx.fillStyle="rgba(255,255,0, 0.5)"; ctx.fill(); ctx.stroke(); // mouth ctx.beginPath(); ctx.moveTo(x+0.4*r, y+10); ctx.arc(x,y+10,0.4*r, 0, Math.PI, true); // eyes var reye = r/10; var f = 0.4; ctx.moveTo(x+f*r, y-f*r); ctx.arc(x+f*r-reye, y-f*r, reye, 0, 2*Math.PI); ctx.moveTo(x-f*r, y-f*r); ctx.arc(x-f*r+reye, y-f*r, reye, -Math.PI, Math.PI); // nose ctx.moveTo(x,y); ctx.lineTo(x, y-r/2); ctx.lineWidth = 1; ctx.stroke(); } // --- Animation of smiley moving with constant speed and bounce back at edges of canvas --- var tprev = 0; // this is used to calculate the time step between two successive calls of run function run(t) { requestAnimationFrame(run); if (t === undefined) { t=0; } var h = t - tprev; // time step tprev = t; SmileyApp.xpos += SmileyApp.xspeed * h/1000; // update position according to constant speed SmileyApp.ypos += SmileyApp.yspeed * h/1000; // update position according to constant speed for (var i=0; i<SmileyReds.length; i++){ SmileyReds[i].xpos += SmileyReds[i].xspeed * h/1000; // update position according to constant speed SmileyReds[i].ypos += SmileyReds[i].yspeed * h/1000; // update position according to constant speed } // change speed direction if smiley hits canvas edges if (lineDistance(SmileyApp.xpos, SmileyApp.ypos) + SmileyApp.radius > 300) { alert("Game Over"); } // redraw smiley at new position ctx.clearRect(0,0,canvas.height, canvas.width); drawBigCircle(); drawSmiley(SmileyApp.xpos, SmileyApp.ypos, SmileyApp.radius); for (var i=0; i<SmileyReds.length; i++){ drawSmileyRed(SmileyReds[i].xpos, SmileyReds[i].ypos, SmileyReds[i].radius); } } // uncomment these two lines to get every going // SmileyApp.speed = 100; run(); // --- Control smiley motion with left/right arrow keys function arrowkeyCB(event) { event.preventDefault(); if (event.keyCode === 37) { // left arrow SmileyApp.xspeed = -100; SmileyApp.yspeed = 0; } else if (event.keyCode === 39) { // right arrow SmileyApp.xspeed = 100; SmileyApp.yspeed = 0; } else if (event.keyCode === 38) { // up arrow SmileyApp.yspeed = -100; SmileyApp.xspeed = 0; } else if (event.keyCode === 40) { // right arrow SmileyApp.yspeed = 100; SmileyApp.xspeed = 0; } } document.addEventListener('keydown', arrowkeyCB, true); JSFiddle : http://jsfiddle.net/gj4Q7/

    Read the article

  • Math for core animation?

    - by jasonbogd
    What is a good level of math required for, like, advanced core animation? Take this for example: http://cocoadex.com/2008/01/lemur-math.html And what's a good book/resource to learn it? -Jason

    Read the article

  • [LaTeX] Math symbols in listings

    - by Michal
    Hi, I have a problem with Latex -- I don't know how to put mathematical equations and symbols in listings. I use --listings-- package and it's offers great looking listings, but it doesn't allow math symbols in $ .. $. Another package --algorithms-- allows math, but listings doesn't look as good as in --listings-- (the problem is that --algorithms-- demands to get new line after every --if--, --then--, etc.) Thanks for reply Michal

    Read the article

  • Solve math question in PHP

    - by Koning WWWWWWWWWWWWWWWWWWWWWWW
    The user can enter a math problem like 5 + 654, 6 ^ 24, 2!, sqrt(543), log(54), sin 5, sin(50). After some reformatting (e.g. change sin 5 into sin(5)), and doing an eval, PHP gives me the right result. However, this is quite unsafe. Can anyone point me in the right direction parsing and solving a math question like the examples above, which is safe? Thanks.

    Read the article

  • How do I transition from physics and math to programming?

    - by inovaovao
    I'm a physics PhD with little actual programming experience. I've always liked programming and played around with BASIC, Pascal as a teen, but the extent of my experience writing complex programs comes from an introductory course in computer science. Now I've decided that I'm more interested in programming than in physics and started to learn Java. Coming from a physics or math-heavy background, what would be the best strategy to maximize my value in the field?

    Read the article

  • MKL Accelerated Math Libraries for Java...

    - by Kaopua
    I've looked at the related threads on StackOverflow and Googled with not much luck. I'm also very new to Java (I'm coming from a C# and .NET background) so please bear with me. There is so much available in the Java world it's pretty overwhelming. I'm starting on a new Java-on-Linux project that requires some heavy and highly repetitious numerical calculations (i.e. statistics, FFT, Linear Algebra, Matrices, etc.). So maximizing the performance of the mathematical operations is a requirement, as is ensuring the math is correct. So hence I have an interest in finding a Java library that perhaps leverages native acceleration such as MKL, and is proven (so commercial options are definitely a possibility here). In the .NET space there are highly optimized and MKL accelerated commercial Mathematical libraries such as Centerspace NMath and Extreme Optimization. Is there anything comparable in Java? Most of the math libraries I have found for Java either do not seem to be actively maintained (such as Colt) or do not appear to leverage MKL or other native acceleration (such as Apache Commons Math). I have considered trying to leverage MKL directly from Java myself (e.g. JNI), but me being new to Java (let alone interoperating between Java and native libraries) it seemed smarter finding a Java library that has already done this correctly, efficiently, and is proven. Again I apologize if I am mistaken or misguided (even in regarding any libraries I've mentioned) and my ignorance of the Java offerings. It's a whole new world for me coming from the heavily commercialized Microsoft stock so I could easily be mistaken on where to look and regarding the Java libraries I've mentioned. I would greatly appreciate any help or advice.

    Read the article

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