Search Results

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

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

  • What are atan and atan2 used for in games?

    - by kyrogue
    I am having some trouble understanding Math.tan() and Math.atan() and Math.atan2(). I have basic knowledge of trigonmetry but the usage of SIN, COS, and TAN etc for game development is very new to me. I am reading on some tutorials and I see that by using tangent we can get the angle in which one object needs to be rotated by how much to face another object for example my mouse. So why do we still need to use atan or atan2?

    Read the article

  • How can I fall in love with Math? Again?

    - by gotts
    After reading How to not sort by average rating by Evan Miller I was really inspired to learn some more math. But after thinking about it for a while I didn't find a way I can use beyond-trivial math in my pet projects.. Or probably it is a moment like "You are not aware that you are not aware" and I should learn more math before I can start to see great examples of how I can apply it?

    Read the article

  • Have any software engineers gotten math degrees later in their careers?

    - by vin
    I have a bachelors in computer science and worked the last 12 years as a software engineer. I'm bored with doing general development work, so I want to specialize. I'm thinking about getting a master's degree in math so I can build math models and write algorithms to implement them. I'm unsure what type of work I'd do (financial, gaming, graphics, science, research, etc) but I'm open minded. I would need to refresh my undergrad math skills (which are old and faded), but I loved algebra and calculus. I've been working with couple statisticians so I've been finding myself more interested in statistics. Since I'm a parent supporting a household, I would have to continue working while studying. Have any software engineers taken this route? (Specifically, going from BS in comp sci to MS in math.) If so, what advice do you have for coursework, financing, and getting a job that combines programming with advanced math? How abundant are these kinds of jobs? I'm not sure where one starts. Also, how do you hop from a BS to an MS in a different subject?

    Read the article

  • How to interpret situations where Math.Acos() reports invalid input?

    - by Sean Ochoa
    Hey all. I'm computing the angle between two vectors, and sometimes Math.Acos() returns NaN when it's input is out of bounds (-1 input && input 1) for a cosine. What does that mean, exactly? Would someone be able to explain what's happening? Any help is appreciated! Here's me method: public double AngleBetween(vector b) { var dotProd = this.Dot(b); var lenProd = this.Len*b.Len; var divOperation = dotProd/lenProd; // http://msdn.microsoft.com/en-us/library/system.math.acos.aspx return Math.Acos(divOperation) * (180.0 / Math.PI); }

    Read the article

  • Define polynomial function

    - by user1822707
    How can I define a function - say, def polyToString(poly) - to return a string containing the polynomial poly in standard form? For example: the polynomial represented by [-1, 2, -3, 4, -5] would be returned as: "-5x**4 + 4x**3 -3x**2 + 2x**1 - 1x**0" def polyToString(poly): standard_form='' n=len(poly) - 1 while n >=0: if poly[n]>=0: if n==len(poly)-1: standard_form= standard_form + ' '+ str(poly[n]) + 'x**%d'%n else: standard_form= standard_form + ' + '+str(poly[n]) + 'x**%d'%n else: standard_form= standard_form + ' - ' + str(abs(poly[n])) + 'x**' + str(n) n=n-1 return standard_form

    Read the article

  • MediaWiki Math Extension Out of Sync

    - by kfmfe04
    I am trying to run MediaWiki 1.19.2 on Ubuntu Linux (3.0.0-26-generic #42-Ubuntu AMD 64). It installs fine via tar.gz, however, I run into problems when trying to install the Math extension (via git clone from its repository). I get the following error in the Apache logs: PHP Fatal error: Call to undefined method FSFileBackend::getRootStoragePath() in /var/www/abc.com/html/mediawiki-1.19.2/extensions/Math/Math.body.php on line 361, referer: http://intra.abc.com/wiki/index.php?title=Quality&action=submit so apparently, the latest Math extension is out-of-sync with MediaWiki 1.19.2; the latest Math extension is apparently using post-1.19.2 methods. I tried looking through the git logs for some indication (a tag, perhaps?) of which revision of Math worked with 1.19.2, but no luck. Anyone have any suggestions? Thanks in advance. Edit: Just my luck - after posting this message, I found this link. I think this version should do the job. Consider this question closed/answered.

    Read the article

  • Is there a Math.atan2 substitute for j2ME? Blackberry development

    - by Kai
    I have a wide variety of locations stored in my persistent object that contain latitudes and longitudes in double(43.7389, 7.42577) format. I need to be able to grab the user's latitude and longitude and select all items within, say 1 mile. Walking distance. I have done this in PHP so I snagged my PHP code and transferred it to Java, where everything plugged in fine until I figured out J2ME doesn't support atan2(double, double). So, after some searching, I find a small snippet of code that is supposed to be a substitute for atan2. Here is the code: public double atan2(double y, double x) { double coeff_1 = Math.PI / 4d; double coeff_2 = 3d * coeff_1; double abs_y = Math.abs(y)+ 1e-10f; double r, angle; if (x >= 0d) { r = (x - abs_y) / (x + abs_y); angle = coeff_1; } else { r = (x + abs_y) / (abs_y - x); angle = coeff_2; } angle += (0.1963f * r * r - 0.9817f) * r; return y < 0.0f ? -angle : angle; } I am getting odd results from this. My min and max latitude and longitudes are coming back as incredibly low numbers that can't possibly be right. Like 0.003785746 when I am expecting something closer to the original lat and long values (43.7389, 7.42577). Since I am no master of advanced math, I don't really know what to look for here. Perhaps someone else may have an answer. Here is my complete code: package store_finder; import java.util.Vector; import javax.microedition.location.Criteria; import javax.microedition.location.Location; import javax.microedition.location.LocationException; import javax.microedition.location.LocationListener; import javax.microedition.location.LocationProvider; import javax.microedition.location.QualifiedCoordinates; import net.rim.blackberry.api.invoke.Invoke; import net.rim.blackberry.api.invoke.MapsArguments; import net.rim.device.api.system.Bitmap; import net.rim.device.api.system.Display; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.Manager; import net.rim.device.api.ui.component.BitmapField; import net.rim.device.api.ui.component.RichTextField; import net.rim.device.api.ui.component.SeparatorField; import net.rim.device.api.ui.container.HorizontalFieldManager; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManager; public class nearBy extends MainScreen { private HorizontalFieldManager _top; private VerticalFieldManager _middle; private int horizontalOffset; private final static long animationTime = 300; private long animationStart = 0; private double latitude = 43.7389; private double longitude = 7.42577; private int _interval = -1; private double max_lat; private double min_lat; private double max_lon; private double min_lon; private double latitude_in_degrees; private double longitude_in_degrees; public nearBy() { super(); horizontalOffset = Display.getWidth(); _top = new HorizontalFieldManager(Manager.USE_ALL_WIDTH | Field.FIELD_HCENTER) { public void paint(Graphics gr) { Bitmap bg = Bitmap.getBitmapResource("bg.png"); gr.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), bg, 0, 0); subpaint(gr); } }; _middle = new VerticalFieldManager() { public void paint(Graphics graphics) { graphics.setBackgroundColor(0xFFFFFF); graphics.setColor(Color.BLACK); graphics.clear(); super.paint(graphics); } protected void sublayout(int maxWidth, int maxHeight) { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); super.sublayout( displayWidth, displayHeight); setExtent( displayWidth, displayHeight); } }; add(_top); add(_middle); Bitmap lol = Bitmap.getBitmapResource("logo.png"); BitmapField lolfield = new BitmapField(lol); _top.add(lolfield); Criteria cr= new Criteria(); cr.setCostAllowed(true); cr.setPreferredResponseTime(60); cr.setHorizontalAccuracy(5000); cr.setVerticalAccuracy(5000); cr.setAltitudeRequired(true); cr.isSpeedAndCourseRequired(); cr.isAddressInfoRequired(); try{ LocationProvider lp = LocationProvider.getInstance(cr); if( lp!=null ){ lp.setLocationListener(new LocationListenerImpl(), _interval, 1, 1); } } catch(LocationException le) { add(new RichTextField("Location exception "+le)); } //_middle.add(new RichTextField("this is a map " + Double.toString(latitude) + " " + Double.toString(longitude))); int lat = (int) (latitude * 100000); int lon = (int) (longitude * 100000); String document = "<location-document>" + "<location lon='" + lon + "' lat='" + lat + "' label='You are here' description='You' zoom='0' />" + "<location lon='742733' lat='4373930' label='Hotel de Paris' description='Hotel de Paris' address='Palace du Casino' postalCode='98000' phone='37798063000' zoom='0' />" + "</location-document>"; // Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document)); _middle.add(new SeparatorField()); surroundingVenues(); _middle.add(new RichTextField("max lat: " + max_lat)); _middle.add(new RichTextField("min lat: " + min_lat)); _middle.add(new RichTextField("max lon: " + max_lon)); _middle.add(new RichTextField("min lon: " + min_lon)); } private void surroundingVenues() { double point_1_latitude_in_degrees = latitude; double point_1_longitude_in_degrees= longitude; // diagonal distance + error margin double distance_in_miles = (5 * 1.90359441) + 10; getCords (point_1_latitude_in_degrees, point_1_longitude_in_degrees, distance_in_miles, 45); double lat_limit_1 = latitude_in_degrees; double lon_limit_1 = longitude_in_degrees; getCords (point_1_latitude_in_degrees, point_1_longitude_in_degrees, distance_in_miles, 135); double lat_limit_2 = latitude_in_degrees; double lon_limit_2 = longitude_in_degrees; getCords (point_1_latitude_in_degrees, point_1_longitude_in_degrees, distance_in_miles, -135); double lat_limit_3 = latitude_in_degrees; double lon_limit_3 = longitude_in_degrees; getCords (point_1_latitude_in_degrees, point_1_longitude_in_degrees, distance_in_miles, -45); double lat_limit_4 = latitude_in_degrees; double lon_limit_4 = longitude_in_degrees; double mx1 = Math.max(lat_limit_1, lat_limit_2); double mx2 = Math.max(lat_limit_3, lat_limit_4); max_lat = Math.max(mx1, mx2); double mm1 = Math.min(lat_limit_1, lat_limit_2); double mm2 = Math.min(lat_limit_3, lat_limit_4); min_lat = Math.max(mm1, mm2); double mlon1 = Math.max(lon_limit_1, lon_limit_2); double mlon2 = Math.max(lon_limit_3, lon_limit_4); max_lon = Math.max(mlon1, mlon2); double minl1 = Math.min(lon_limit_1, lon_limit_2); double minl2 = Math.min(lon_limit_3, lon_limit_4); min_lon = Math.max(minl1, minl2); //$qry = "SELECT DISTINCT zip.zipcode, zip.latitude, zip.longitude, sg_stores.* FROM zip JOIN store_finder AS sg_stores ON sg_stores.zip=zip.zipcode WHERE zip.latitude<=$lat_limit_max AND zip.latitude>=$lat_limit_min AND zip.longitude<=$lon_limit_max AND zip.longitude>=$lon_limit_min"; } private void getCords(double point_1_latitude, double point_1_longitude, double distance, int degs) { double m_EquatorialRadiusInMeters = 6366564.86; double m_Flattening=0; double distance_in_meters = distance * 1609.344 ; double direction_in_radians = Math.toRadians( degs ); double eps = 0.000000000000005; double r = 1.0 - m_Flattening; double point_1_latitude_in_radians = Math.toRadians( point_1_latitude ); double point_1_longitude_in_radians = Math.toRadians( point_1_longitude ); double tangent_u = (r * Math.sin( point_1_latitude_in_radians ) ) / Math.cos( point_1_latitude_in_radians ); double sine_of_direction = Math.sin( direction_in_radians ); double cosine_of_direction = Math.cos( direction_in_radians ); double heading_from_point_2_to_point_1_in_radians = 0.0; if ( cosine_of_direction != 0.0 ) { heading_from_point_2_to_point_1_in_radians = atan2( tangent_u, cosine_of_direction ) * 2.0; } double cu = 1.0 / Math.sqrt( ( tangent_u * tangent_u ) + 1.0 ); double su = tangent_u * cu; double sa = cu * sine_of_direction; double c2a = ( (-sa) * sa ) + 1.0; double x= Math.sqrt( ( ( ( 1.0 /r /r ) - 1.0 ) * c2a ) + 1.0 ) + 1.0; x= (x- 2.0 ) / x; double c= 1.0 - x; c= ( ( (x * x) / 4.0 ) + 1.0 ) / c; double d= ( ( 0.375 * (x * x) ) -1.0 ) * x; tangent_u = distance_in_meters /r / m_EquatorialRadiusInMeters /c; double y= tangent_u; boolean exit_loop = false; double cosine_of_y = 0.0; double cz = 0.0; double e = 0.0; double term_1 = 0.0; double term_2 = 0.0; double term_3 = 0.0; double sine_of_y = 0.0; while( exit_loop != true ) { sine_of_y = Math.sin(y); cosine_of_y = Math.cos(y); cz = Math.cos( heading_from_point_2_to_point_1_in_radians + y); e = (cz * cz * 2.0 ) - 1.0; c = y; x = e * cosine_of_y; y = (e + e) - 1.0; term_1 = ( sine_of_y * sine_of_y * 4.0 ) - 3.0; term_2 = ( ( term_1 * y * cz * d) / 6.0 ) + x; term_3 = ( ( term_2 * d) / 4.0 ) -cz; y= ( term_3 * sine_of_y * d) + tangent_u; if ( Math.abs(y - c) > eps ) { exit_loop = false; } else { exit_loop = true; } } heading_from_point_2_to_point_1_in_radians = ( cu * cosine_of_y * cosine_of_direction ) - ( su * sine_of_y ); c = r * Math.sqrt( ( sa * sa ) + ( heading_from_point_2_to_point_1_in_radians * heading_from_point_2_to_point_1_in_radians ) ); d = ( su * cosine_of_y ) + ( cu * sine_of_y * cosine_of_direction ); double point_2_latitude_in_radians = atan2(d, c); c = ( cu * cosine_of_y ) - ( su * sine_of_y * cosine_of_direction ); x = atan2( sine_of_y * sine_of_direction, c); c = ( ( ( ( ( -3.0 * c2a ) + 4.0 ) * m_Flattening ) + 4.0 ) * c2a * m_Flattening ) / 16.0; d = ( ( ( (e * cosine_of_y * c) + cz ) * sine_of_y * c) + y) * sa; double point_2_longitude_in_radians = ( point_1_longitude_in_radians + x) - ( ( 1.0 - c) * d * m_Flattening ); heading_from_point_2_to_point_1_in_radians = atan2( sa, heading_from_point_2_to_point_1_in_radians ) + Math.PI; latitude_in_degrees = Math.toRadians( point_2_latitude_in_radians ); longitude_in_degrees = Math.toRadians( point_2_longitude_in_radians ); } public double atan2(double y, double x) { double coeff_1 = Math.PI / 4d; double coeff_2 = 3d * coeff_1; double abs_y = Math.abs(y)+ 1e-10f; double r, angle; if (x >= 0d) { r = (x - abs_y) / (x + abs_y); angle = coeff_1; } else { r = (x + abs_y) / (abs_y - x); angle = coeff_2; } angle += (0.1963f * r * r - 0.9817f) * r; return y < 0.0f ? -angle : angle; } private Vector fetchVenues(double max_lat, double min_lat, double max_lon, double min_lon) { return new Vector(); } private class LocationListenerImpl implements LocationListener { public void locationUpdated(LocationProvider provider, Location location) { if(location.isValid()) { nearBy.this.longitude = location.getQualifiedCoordinates().getLongitude(); nearBy.this.latitude = location.getQualifiedCoordinates().getLatitude(); //double altitude = location.getQualifiedCoordinates().getAltitude(); //float speed = location.getSpeed(); } } public void providerStateChanged(LocationProvider provider, int newState) { // MUST implement this. Should probably do something useful with it as well. } } } please excuse the mess. I have the user lat long hard coded since I do not have GPS functional yet. You can see the SQL query commented out to know how I plan on using the min and max lat and long values. Any help is appreciated. Thanks

    Read the article

  • How do I insert a newline within a long formula using OpenOffice.org Math?

    - by Lekensteyn
    I've the following formula: (x^6+x^4+x^2+x+1)(x^7+x+1) = x^13+x^11+x^9+x^8+x^7+ x^7+x^5+x^3+x^3+x^2+x+ x^6+x^4+x^2+x+1 = x^13+x^11+x^9+x^8+2x^7+x^6+x^5+x^4+2x^3+2x^2+2x+1 Putting this in OpenOffice.org Math causes every line be concatenated, which I want to avoid. I've already tried putting newline between the lines, but it adds a strange question mark in the formula. Using matrices did not work for me either. I want to achieve a nicely formatted formula like this one (taken from FIPS 197 pdf):

    Read the article

  • Matrix Math in SQL

    Relational Datbases have tables as data structures, not arrays. This makes it tricky and slow to do matrix operations, but it doesn't mean it is impossible to do. Joe gives the Celko Slant on how to go about doing Matrix Math in SQL. 12 essential tools for database professionalsThe SQL Developer Bundle contains 12 tools designed with the SQL Server developer and DBA in mind. Try it now.

    Read the article

  • How can I learn the math necessary for working with computer vision?

    - by Duncan Benoit
    I know that computer vision involves a lot of math, but I need some tips about how programmers gain that knowledge. I've started to use the OpenCV library but I have some major problems in understanding how the math works in the algorithms. In college I have studied some math and we worked with matrices and derivatives, but I didn't pay to much attention to the subject. It seemed to be so difficult and useless from a programmer point of view. I suppose that there has to be some easy way to understand what a second derivative is without calculating an equation. (Derivatives are just an example) Do you have any tips for me about how can i gain such knowledge? A forum, book, link, advice, anything?

    Read the article

  • How to JSON serialize math vector type in F#?

    - by The_Ghost
    Hello! I'm trying to serialize "vector" (Microsoft.FSharp.Math) type. And I get that error: Exception Details: System.Runtime.Serialization.SerializationException: Type 'Microsoft.FSharp.Math.Instances+FloatNumerics@115' with data contract name 'Instances.FloatNumerics_x0040_115:http://schemas.datacontract.org/2004/07/Microsoft.FSharp.Math' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer. I have tried to put KnownType attribute and some other stuff, but nothing helps! Could someone know the answer? This is the code I use: // [< KnownType( typeof<vector> ) >] type MyType = vector let public writeTest = let aaa = vector [1.1;2.2] let serializer = new DataContractJsonSerializer( typeof<MyType> ) let writer = new StreamWriter( @"c:\test.txt" ) serializer.WriteObject(writer.BaseStream, aaa) writer.Close()

    Read the article

  • snapping an angle to the closest cardinal direction

    - by Josh E
    I'm developing a 2D sprite-based game, and I'm finding that I'm having trouble with making the sprites rotate correctly. In a nutshell, I've got spritesheets for each of 5 directions (the other 3 come from just flipping the sprite horizontally), and I need to clamp the velocity/rotation of the sprite to one of those directions. My sprite class has a pre-computed list of radians corresponding to the cardinal directions like this: protected readonly List<float> CardinalDirections = new List<float> { MathHelper.PiOver4, MathHelper.PiOver2, MathHelper.PiOver2 + MathHelper.PiOver4, MathHelper.Pi, -MathHelper.PiOver4, -MathHelper.PiOver2, -MathHelper.PiOver2 + -MathHelper.PiOver4, -MathHelper.Pi, }; Here's the positional update code: if (velocity == Vector2.Zero) return; var rot = ((float)Math.Atan2(velocity.Y, velocity.X)); TurretRotation = SnapPositionToGrid(rot); var snappedX = (float)Math.Cos(TurretRotation); var snappedY = (float)Math.Sin(TurretRotation); var rotVector = new Vector2(snappedX, snappedY); velocity *= rotVector; //...snip private float SnapPositionToGrid(float rotationToSnap) { if (rotationToSnap == 0) return 0.0f; var targetRotation = CardinalDirections.First(x => (x - rotationToSnap >= -0.01 && x - rotationToSnap <= 0.01)); return (float)Math.Round(targetRotation, 3); } What am I doing wrong here? I know that the SnapPositionToGrid method is far from what it needs to be - the .First(..) call is on purpose so that it throws on no match, but I have no idea how I would go about accomplishing this, and unfortunately, Google hasn't helped too much either. Am I thinking about this the wrong way, or is the answer staring at me in the face?

    Read the article

  • Polygon is rotating too fast

    - by Manderin87
    I am going to be using a polygon collision detection method to test when objects collide. I am attempting to rotate a polygon to match the sprites rotation. However, the polygon is rotating too fast, much faster than the sprite is. I feel its a timing issue, but the sprite rotates like it is supposed to. Can anyone look at my code and tell me what could be causing this issue? public void rotate(float x0, float y0, double angle) { for(Point point : mPoints) { float x = (float) (x0 + (point.x - x0) * Math.cos(Utilities.toRadians(angle)) - (point.y - y0) * Math.sin(Utilities.toRadians(angle))); float y = (float) (y0 + (point.x - x0) * Math.sin(Utilities.toRadians(angle)) + (point.y - y0) * Math.cos(Utilities.toRadians(angle))); point.x = x; point.y = y; } } This algorithm works when done singly, but once I plug it into the update method the rotation is too fast. The Points used are: P1 608, 368 P2 640, 464 P3 672, 400 Origin x0 is: 640 400 The angle goes from 0 to 360 as the sprite rotates. When the codes executes the triangle looks like a star because its moving so fast. The rotation is done in the sprites update method. The rotation method just increases the sprites degree by .5 when it executes. public void update() { if(isActive()) { rotate(); mBounding.rotate(mPosition.x, mPosition.y, mDegree); } }

    Read the article

  • Making user input/math on data fast, unlike excel type programs

    - by proGrammar
    I'm creating a research platform solely for myself to do some research on data. Programs like excel are terribly slow for me so I'm trying to come up with another solution. Originally I used excel. A1 was the cell that contained the data and all other cells in use calculated something on A1, or on other cells, that all could be in the end traced to A1. A1 was like an element of an array, I then I incremented it to go through all my data. This was way too slow. So the only other option I found originally was to hand code in c# the calculations inside a loop. Then I simply recompiled each time I changed my math. This was terribly slow to do and I had to order everything correctly so things would update correctly (dependencies). I could have also used events, but hand coding events for each cell like calculation would also be very slow. Next I created an application to read Excel and to perfectly imitate it. Which is what I now use. Basically I write formulas onto a fraction of my data to get live results inside excel. Then my program reads excel, writes another c# program, compiles it, and runs that program which runs my excel created formulas through a lot more data a whole lot faster. The advantage being my application dependency sorts everything (or I could use events) so I don't have to (like excel does) And of course the speed. But now its not a single application anymore. Instead its 2 applications, one which only reads my formulas and writes another program. The other one being the result which only lives for a short while before I do other runs through my data with different formulas / settings. So I can't see multiple results at one time without introducing even more programs like a database or at least having the 2 applications talking to each other. My idea was to have a dll that would be written, compiled, loaded, and unloaded again and again. So a self-updating program, sort of. But apparently that's not possible without another appdomain which means data has to be marshaled to be moved between the appdomains. Which would slow things down, not for summaries, but for other stuff I need to do with all my data. I'm also forgetting to mention a huge problem with restarting an application again and again which is having to reload ALL my data into memory again and again. But its still a whole lot faster than excel. I'm really super puzzled as to what people do when they want to research data fast. I'm completely unable to have a program accept user input and having it fast. My understanding is that it would have to do things like excel which is to evaluate strings again and again. So my only option is to repeatedly compile applications. Do I have a correct understanding on computer science? I've only just began programming, and didn't think I would have to learn much to do some simple math on data. My understanding is its either compiling my user defined stuff to a program or evaluating them from a string or something stupid again and again. And my only option is to probably switch operating systems or something to be able to have a program compile and run itself without stopping (writing/compiling dll, loading dll to program, unloading, and repeating). Can someone give me some idea on how computers work? Is anything better possible? Like a running program, that can accept user input and compile it and then unload it later? I mean heck operating systems dont need to be RESTARTED with every change to user input. What is this the cave man days? Sorry, it's just so super frustrating not knowing what one can do, and can't do. If only I could understand and learn this stuff fast enough.

    Read the article

  • Traveling Salesman in polynomial time

    - by Andres
    Problem Description: Write a program in any language with the shortest number of characters that solves the following problem: Given a collection of cities and the cost of travel between each pair of them, find the cheapest way of visiting all of the cities and returning to your starting point. All solutions must take at most polynomial time. Input will be in the form of a text file named simply "i". The text file will contain data in the following format: city1# city2# cost$ cityA# cityB# cost$ ... Each element in the file is separated with a space, and there is a newline at the end of every line. Code count does not include whitespace. Solutions that take longer than polynomial time to find will not be accepted

    Read the article

  • Create a polynomial object from a number using change-class

    - by charlieb
    I have written a polynomial class along the lines described in SICP 2.5.3 (except using defclass). I would like to be able to seamlessly add and multiply polynomials and regular numbers but I can't make change-class accept a number. I tried to simplify the problem by changing class from an integer to a float: (change-class 4 'float) but that gave me the error: There is no applicable method for the generic function #<STANDARD-GENERIC-FUNCTION CHANGE-CLASS (7)> when called with arguments (4 #<BUILT-IN-CLASS FLOAT>). [Condition of type SIMPLE-ERROR] I get an error of the same form from (fyi): (change-class 4 'polynomial) I'm going to go ahead and implement a manual conversion but I would prefer to use the built-in clos facilities.

    Read the article

  • Isometric - precise screen coordinates to isometric

    - by Rawrz
    I'm trying to translate mouse coords to precise isometric coords (I can already find the tile the mouse is over, but I want it to be more precise). I've tried several different methods but I seem to keep falling short. For drawing I use: batch.draw( texture, (y * tileWidth / 2) + (x * tileWidth / 2), (x * tileHeight / 2) - (y * tileHeight / 2)) This is what I currently use for figuring out a tile position: float xt = x + camPosition.x - (ScreenWidth/2) ; float yt = (ScreenHeight) - y + camPosition.y - (ScreenHeight/2); int tileY = Math.round((((xt) / tileWidth) - ((yt) / tileHeight))); int tileX = Math.round((((xt) / tileWidth) + ((yt) / tileHeight))- 1); I'm just wondering how I could update these to allow for more precise coordinates, instead of tile only. EDIT: Following what ccxvii said below, and removing the -1 from tileX, the object follows my mouse just like I had wanted. Just going to re-examine the math and figure out if that change will result in other messes =o

    Read the article

  • Raycasting tutorial / vector math question

    - by mattboy
    I'm checking out this nice raycasting tutorial at http://lodev.org/cgtutor/raycasting.html and have a probably very simple math question. In the DDA algorithm I'm having trouble understanding the calcuation of the deltaDistX and deltaDistY variables, which are the distances that the ray has to travel from 1 x-side to the next x-side, or from 1 y-side to the next y-side, in the square grid that makes up the world map (see below screenshot). In the tutorial they are calculated as follows, but without much explanation: //length of ray from one x or y-side to next x or y-side double deltaDistX = sqrt(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX)); double deltaDistY = sqrt(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY)); rayDirY and rayDirX are the direction of a ray that has been cast. How do you get these formulas? It looks like pythagorean theorem is part of it, but somehow there's division involved here. Can anyone clue me in as to what mathematical knowledge I'm missing here, or "prove" the formula by showing how it's derived?

    Read the article

  • Third-Grade Math Class

    - by andyleonard
    An Odd Thing Happened... ... when I was in third grade math class: I was handed a sheet of arithmetic problems to solve. There were maybe 20 problems on the page and we were given the remainder of the class to complete them. I don't remember how much time remained in the class, I remember I finished working on the problems before my classmates. That wasn't the odd part. The odd part was that I started working on the first problem, concentrating pretty hard. I worked the sum and moved to the next...(read more)

    Read the article

  • How does a website like Mathway work?

    - by Bob
    I recently found a website called Mathway Basically, it works by allowing you to choose your "level of math" (which it uses to determine what tools it should provide to you) and then allows you to input a math problem which it then solves for you, and gives you detailed solutions (you have to try it, it's really cool). I was wondering how it worked on two levels. First off, how would they parse the math problem (and all the sometimes foreign mathematical operators)? How do they get from text to numbers, variables, and operators? Second, how do they generate the explanations? While you have to pay for the detailed solutions (which are explanations of how they solved the problem), I've seen their preview screenshots, and it looks very detailed. The explanations are given in full, accurate sentences. How would they generate something like that?

    Read the article

  • Rotate a vector by given degrees (errors when value over 90)

    - by Ivan
    I created a function to rotate a vector by a given number of degrees. It seems to work fine when given values in the range -90 to +90. Beyond this, the amount of rotation decreases, i.e., I think objects are rotating the same amount for 80 and 100 degrees. I think this diagram might be a clue to my problem, but I don't quite understand what it's showing. Must I use a different trig function depending on the radians value? The programming examples I've been able to find look similar to mine (not varying the trig functions). Vector2D.prototype.rotate = function(angleDegrees) { var radians = angleDegrees * (Math.PI / 180); var ca = Math.cos(radians); var sa = Math.sin(radians); var rx = this.x*ca - this.y*sa; var ry = this.x*sa + this.y*ca; this.x = rx; this.y = ry; };

    Read the article

  • Math behind multivariate testing for website optimization

    - by corkjack
    I am looking for theoretical resources (books, tutorials, etc.) to learn about making sound statistical inferences given (plenty of) multivariate website conversion data. I'm after the math involved, and cannot find any good non-marketing stuff on the web. The sort of questions I want to answer: how much impact does a single variable (e.g. color of text) have? what is the correlation between variables? what type of distribution is used for modelling (Gaussian, Binomial, etc.)? When using statistics to analyze results - what should be considered as a random variable - the web-page element that gets different variations or the binary conversion-or-no-conversion outcome of an impression? There's plenty of information about different website optimization testing methods and their benefits\pitfalls, plenty of information about multivariate statistics in general, do you guys know of resources that discuss statistics in this specific context of website optimization ? Thanks for any info!

    Read the article

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