Search Results

Search found 521 results on 21 pages for 'calculator'.

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

  • Creating simple calculator with bison & flex in C++ (not C)

    - by ak91
    Hey, I would like to create simple C++ calculator using bison and flex. Please note I'm new to the creating parsers. I already found few examples in bison/flex but they were all written in C. My goal is to create C++ code, where classes would contain nodes of values, operations, funcs - to create AST (evaluation would be done just after creating whole AST - starting from the root and going forward). For example: my_var = sqrt(9 ** 2 - 32) + 4 - 20 / 5 my_var * 3 Would be parsed as: = / \ my_var + / \ sqrt - | / \ - 4 / / \ / \ ** 32 20 5 / \ 9 2 and the second AST would look like: * / \ my_var 3 Then following pseudocode reflects AST: ast_root = create_node('=', new_variable("my_var"), exp) where exp is: exp = create_node(OPERATOR, val1, val2) but NOT like this: $$ = $1 OPERATOR $3 because this way I directly get value of operation instead of creation the Node. I believe the Node should contain type (of operation), val1 (Node), val2 (Node). In some cases val2 would be NULL, like above mentioned sqrt which takes in the end one argument. Right? It will be nice if you can propose me C++ skeleton (without evaluation) for above described problem (including *.y file creating AST) to help me understand the way of creating/holding Nodes in AST. Code can be snipped, just to let me get the idea. I'll also be grateful if you point me to an existing (possibly simple) example if you know any. Thank you all for your time and assistance!

    Read the article

  • Obtaining XML from U.S. Postal Service (USPS) rate calculator API with PHP

    - by Chris F
    hoping somebody here can help me. I'm attempting to pull an XML page from the U.S. Postal Service (USPS) rate calculator, using PHP. Here is the code I am using (with my API login and password replaced of course): <? $api = "http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=<RateV4Request ". "USERID=\"MYUSERID\" PASSWORD=\"MYPASSWORD\"><Revision/><Package ID=\"1ST\">". "<Service>FIRST CLASS</Service><FirstClassMailType>PARCEL</FirstClassMailType>". "<ZipOrigination>12345</ZipOrigination><ZipDestination>54321</ZipDestination>". "<Pounds>0</Pounds><Ounces>9</Ounces><Container/><Size>REGULAR</Size></Package></RateV4Request>"; $xml_string = file_get_contents($api); $xml = simplexml_load_string($xml_string); ?> Pretty straightforward. However it never returns anything. I can paste the URL directly into my browser's address bar: http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=<RateV4RequestUSERID="MYUSERID" PASSWORD="MYPASSWORD"><Revision/><Package ID="1ST"><Service>FIRST CLASS</Service><FirstClassMailType>PARCEL</FirstClassMailType><ZipOrigination>12345</ZipOrigination><ZipDestination>54321</ZipDestination><Pounds>0</Pounds><Ounces>9</Ounces><Container/><Size>REGULAR</Size></Package></RateV4Request> And it returns the XML I need, so I know the URL is valid. But I cannot seem to capture it using PHP. Any help would be tremendously appreciated. Thanks in advance.

    Read the article

  • Design pattern for cost calculator app?

    - by Anders Svensson
    Hi, I have a problem that I’ve tried to get help for before, but I wasn’t able to solve it then, so I’m trying to simplify the problem now to see if I can get some more concrete help with this because it is driving me crazy… Basically, I have a working (more complex) version of this application, which is a project cost calculator. But because I am at the same time trying to learn to design my applications better, I would like some input on how I could improve this design. Basically the main thing I want is input on the conditionals that (here) appear repeated in two places. The suggestions I got before was to use the strategy pattern or factory pattern. I also know about the Martin Fowler book with the suggestion to Refactor conditional with polymorphism. I understand that principle in his simpler example. But how can I do either of these things here (if any would be suitable)? The way I see it, the calculation is dependent on a couple of conditions: 1. What kind of service is it, writing or analysis? 2. Is the project small, medium or large? (Please note that there may be other parameters as well, equally different, such as “are the products new or previously existing?” So such parameters should be possible to add, but I tried to keep the example simple with only two parameters to be able to get concrete help) So refactoring with polymorphism would imply creating a number of subclasses, which I already have for the first condition (type of service), and should I really create more subclasses for the second condition as well (size)? What would that become, AnalysisSmall, AnalysisMedium, AnalysisLarge, WritingSmall, etc…??? No, I know that’s not good, I just don’t see how to work with that pattern anyway else? I see the same problem basically for the suggestions of using the strategy pattern (and the factory pattern as I see it would just be a helper to achieve the polymorphism above). So please, if anyone has concrete suggestions as to how to design these classes the best way I would be really grateful! Please also consider whether I have chosen the objects correctly too, or if they need to be redesigned. (Responses like "you should consider the factory pattern" will obviously not be helpful... I've already been down that road and I'm stumped at precisely how in this case) Regards, Anders The code (very simplified, don’t mind the fact that I’m using strings instead of enums, not using a config file for data etc, that will be done as necessary in the real application once I get the hang of these design problems): public abstract class Service { protected Dictionary<string, int> _hours; protected const int SMALL = 2; protected const int MEDIUM = 8; public int NumberOfProducts { get; set; } public abstract int GetHours(); } public class Writing : Service { public Writing(int numberOfProducts) { NumberOfProducts = numberOfProducts; _hours = new Dictionary<string, int> { { "small", 125 }, { "medium", 100 }, { "large", 60 } }; } public override int GetHours() { if (NumberOfProducts <= SMALL) return _hours["small"] * NumberOfProducts; if (NumberOfProducts <= MEDIUM) return (_hours["small"] * SMALL) + (_hours["medium"] * (NumberOfProducts - SMALL)); return (_hours["small"] * SMALL) + (_hours["medium"] * (MEDIUM - SMALL)) + (_hours["large"] * (NumberOfProducts - MEDIUM)); } } public class Analysis : Service { public Analysis(int numberOfProducts) { NumberOfProducts = numberOfProducts; _hours = new Dictionary<string, int> { { "small", 56 }, { "medium", 104 }, { "large", 200 } }; } public override int GetHours() { if (NumberOfProducts <= SMALL) return _hours["small"]; if (NumberOfProducts <= MEDIUM) return _hours["medium"]; return _hours["large"]; } } public partial class Form1 : Form { public Form1() { InitializeComponent(); List<int> quantities = new List<int>(); for (int i = 0; i < 100; i++) { quantities.Add(i); } comboBoxNumberOfProducts.DataSource = quantities; } private void comboBoxNumberOfProducts_SelectedIndexChanged(object sender, EventArgs e) { Service writing = new Writing((int) comboBoxNumberOfProducts.SelectedItem); Service analysis = new Analysis((int) comboBoxNumberOfProducts.SelectedItem); labelWriterHours.Text = writing.GetHours().ToString(); labelAnalysisHours.Text = analysis.GetHours().ToString(); } }

    Read the article

  • C# 4.0: Dynamic Programming

    - by Paulo Morgado
    The major feature of C# 4.0 is dynamic programming. Not just dynamic typing, but dynamic in broader sense, which means talking to anything that is not statically typed to be a .NET object. Dynamic Language Runtime The Dynamic Language Runtime (DLR) is piece of technology that unifies dynamic programming on the .NET platform, the same way the Common Language Runtime (CLR) has been a common platform for statically typed languages. The CLR always had dynamic capabilities. You could always use reflection, but its main goal was never to be a dynamic programming environment and there were some features missing. The DLR is built on top of the CLR and adds those missing features to the .NET platform. The Dynamic Language Runtime is the core infrastructure that consists of: Expression Trees The same expression trees used in LINQ, now improved to support statements. Dynamic Dispatch Dispatches invocations to the appropriate binder. Call Site Caching For improved efficiency. Dynamic languages and languages with dynamic capabilities are built on top of the DLR. IronPython and IronRuby were already built on top of the DLR, and now, the support for using the DLR is being added to C# and Visual Basic. Other languages built on top of the CLR are expected to also use the DLR in the future. Underneath the DLR there are binders that talk to a variety of different technologies: .NET Binder Allows to talk to .NET objects. JavaScript Binder Allows to talk to JavaScript in SilverLight. IronPython Binder Allows to talk to IronPython. IronRuby Binder Allows to talk to IronRuby. COM Binder Allows to talk to COM. Whit all these binders it is possible to have a single programming experience to talk to all these environments that are not statically typed .NET objects. The dynamic Static Type Let’s take this traditional statically typed code: Calculator calculator = GetCalculator(); int sum = calculator.Sum(10, 20); Because the variable that receives the return value of the GetCalulator method is statically typed to be of type Calculator and, because the Calculator type has an Add method that receives two integers and returns an integer, it is possible to call that Sum method and assign its return value to a variable statically typed as integer. Now lets suppose the calculator was not a statically typed .NET class, but, instead, a COM object or some .NET code we don’t know he type of. All of the sudden it gets very painful to call the Add method: object calculator = GetCalculator(); Type calculatorType = calculator.GetType(); object res = calculatorType.InvokeMember("Add", BindingFlags.InvokeMethod, null, calculator, new object[] { 10, 20 }); int sum = Convert.ToInt32(res); And what if the calculator was a JavaScript object? ScriptObject calculator = GetCalculator(); object res = calculator.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res); For each dynamic domain we have a different programming experience and that makes it very hard to unify the code. With C# 4.0 it becomes possible to write code this way: dynamic calculator = GetCalculator(); int sum = calculator.Add(10, 20); You simply declare a variable who’s static type is dynamic. dynamic is a pseudo-keyword (like var) that indicates to the compiler that operations on the calculator object will be done dynamically. The way you should look at dynamic is that it’s just like object (System.Object) with dynamic semantics associated. Anything can be assigned to a dynamic. dynamic x = 1; dynamic y = "Hello"; dynamic z = new List<int> { 1, 2, 3 }; At run-time, all object will have a type. In the above example x is of type System.Int32. When one or more operands in an operation are typed dynamic, member selection is deferred to run-time instead of compile-time. Then the run-time type is substituted in all variables and normal overload resolution is done, just like it would happen at compile-time. The result of any dynamic operation is always dynamic and, when a dynamic object is assigned to something else, a dynamic conversion will occur. Code Resolution Method double x = 1.75; double y = Math.Abs(x); compile-time double Abs(double x) dynamic x = 1.75; dynamic y = Math.Abs(x); run-time double Abs(double x) dynamic x = 2; dynamic y = Math.Abs(x); run-time int Abs(int x) The above code will always be strongly typed. The difference is that, in the first case the method resolution is done at compile-time, and the others it’s done ate run-time. IDynamicMetaObjectObject The DLR is pre-wired to know .NET objects, COM objects and so forth but any dynamic language can implement their own objects or you can implement your own objects in C# through the implementation of the IDynamicMetaObjectProvider interface. When an object implements IDynamicMetaObjectProvider, it can participate in the resolution of how method calls and property access is done. The .NET Framework already provides two implementations of IDynamicMetaObjectProvider: DynamicObject : IDynamicMetaObjectProvider The DynamicObject class enables you to define which operations can be performed on dynamic objects and how to perform those operations. For example, you can define what happens when you try to get or set an object property, call a method, or perform standard mathematical operations such as addition and multiplication. ExpandoObject : IDynamicMetaObjectProvider The ExpandoObject class enables you to add and delete members of its instances at run time and also to set and get values of these members. This class supports dynamic binding, which enables you to use standard syntax like sampleObject.sampleMember, instead of more complex syntax like sampleObject.GetAttribute("sampleMember").

    Read the article

  • Recognizing Tail-recursive functions with Flex+Bison and convert code to an Iterative form

    - by Viet
    I'm writing a calculator with an ability to accept new function definitions. Being aware of the need of newbies to try recursive functions such as Fibonacci, I would like my calculator to be able to recognize Tail-recursive functions with Flex + Bison and convert code to an Iterative form. I'm using Flex & Bison to do the job. If you have any hints or ideas, I welcome them warmly. Thanks!

    Read the article

  • Distance by sea calculator, intermediate coordinates?

    - by Lucian2k
    How do I calculate distance between 2 coordinates by sea? I also want to be able to draw a route between the two coordinates. Only solution I found so far is to split a map into pixels, identify each pixel as LAND or SEA and then try to find the path using A* algorithm. Then transform pixels to relative coordinates. There are some software packages I could buy but none have online extensions. A service that calculates distances between sea ports and plots the path on a map is searates.com

    Read the article

  • how is google Calculator implemented ?

    - by AlgoMan
    When you search in Google "100F to C" how does it know to convert from Fahrenheit to Celsius. Similarly, conversion from different currencies and simple calculation. What is the data structure used. Or is it simple pattern matching the strings ?

    Read the article

  • Android calculator with button click

    - by rynwtts
    I am trying to calculate a field named lblAnswer by adding values txtA + txtB. I am fairly new to the android development world and would like to know what is the best way of going about this. I have already added the necessarily edit fields to the GUI. I am now working in the java file to try and create the method. This method has been named doCalc. Here is what I have thus far. public void doCalc() { lblAnswer = txtA + txtB; } It has been suggested that I add more code here is the full code. Thank you for that suggestion. Here is the Java File. package com.example.wattsprofessional; import android.app.Activity; import android.os.Bundle; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } public void doCalc() { lblAnswer = txtA + txtB; Double.parseDouble(txtA.getText().toString()); lblAnswer.setText"t } and here is the xml file. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <EditText android:id="@+id/txtA" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="40dp" android:ems="10" android:hint="Write Here" android:inputType="numberDecimal" > <requestFocus /> </EditText> <EditText android:id="@+id/txtB" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/txtA" android:layout_below="@+id/txtA" android:layout_marginTop="32dp" android:ems="10" android:hint="Second Here" android:inputType="numberDecimal" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/calculate" android:onClick="doCalc"/> <TextView android:id="@+id/lblAnswer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button1" android:layout_centerHorizontal="true" android:layout_marginTop="50dp" android:text="TextView" /> </RelativeLayout>

    Read the article

  • Code Golf: Banknote calculator

    - by paxdiablo
    This question was posted by a C beginner and it was an exercise to calculate, given a dollar value input by the user, the minimum number of bills (or banknotes, depending on your locale) needed to reach that dollar value. So, if the user entered 93, the output would be: $20 bills = 4 $10 bills = 1 $5 bills = 0 $1 bills = 3 Finally succumbing to the phenomenon (it's a slow day here), I thought this would be ripe for a game of Code Golf. For fairness, the input prompt needs to be (note the "_" at the end is a space): Enter a dollar amount:_ I think I've covered all the bases: no identical question, community wiki. I won't be offended if it gets shut down though - of course, I'll never be able to complain about these types of questions again, for fear of being labelled a hypocrite :-) Okay, let's see what you can come up with. Here's a sample run: Enter a dollar amount: 127 $20 bills = 6 $10 bills = 0 $5 bills = 1 $1 bills = 2

    Read the article

  • How to make a calculator in PHP?

    - by Giulio Muscarello
    I want to use PHP to calculate simple algebraic expressions like, 8*(5+1), entered via an <input> tag by a normal user (which means, normal notation: no syntax changes like Multiply(8, Add(5, 1))). Also, it has to show all steps, but that's not hard. The problem, right now, is calculating the value of the expressions. Note: this is what I thought so far, which is quite inefficient but it's a provisory solution. Just replace strings where possible: in our example, recognize the string 5+1 and replace it with 6. Then, loop again, replace (6) with 6, loop again, and replace 8*6 with 48. The code for multiplying, for example, should look like this: for ($a=1; $a < 1000; $a++) { for ($b=1; $b < 1000; $b++) { string_replace($a . '*' . $b, $a*$b, $string); } }

    Read the article

  • C# compile error for simple Annual Salary Calculator

    - by Mike Vignapiano
    I am new to C# and trying to create my 1st app. I have 3 errors. The first two say that txtSalary and Salary do not exist. The 3rd says that it cannot convert method group 'ToString' to non-delegate type 'string'. and asks if I intend to invoke the method. Here is what I have: protected void Button1_Click(object sender, EventArgs e) { int salary, AnnualHours, Rate; string txtAnnualHours, txtSalary, txtRate; salary = AnnualHours * Rate; txtsalary = int.Parse(Salary); txtAnnualHours = salary.ToString; MessageBox.Show(salary); } According to my book, when you enter numerics in AnnualHours and Rate textbox, when click Button1, these values are converted from string to integers, then multiplied for salary. Then numeric answer converted to string and displayed in messagebox named txtSalary. Please show me what I got wrong because according to the book, I am not missing anything.

    Read the article

  • jQuery date calculator - show/hide IMG

    - by utopicam
    I have a problem with the following code. I tried changing many things (symbols, classes, imgs in the code) but this is killing me and I have no idea how to fix it. Sorry it's so specific, when solved I'll change the title to something more useful. I have two images. My jquery has to calculate the day and show one image or the other depending on that (using a class with display:none). My month has 24 days (it's a xmas thing). This is what I have so far: <script type="text/javascript"> $(document).ready(function(){ var currentTime = new Date() var day = currentTime.getDate(); if (day > 24){ day = 1; } $(".calDate").each(function(){ var curDate = $(this).attr("date"); if (curDate < day){ $(this).addClass("xMasPast"); } else if(curDate==day){ $(this).addClass("xMasActive"); } else { $(this).addClass("xMasInactive"); } }); $(".calDate2").each(function(){ var curDate = $(this).attr("date"); if (curDate > day){ $(this).addClass("xMasInactive"); } else if(curDate==day){ $(this).addClass("xMasActive"); } else { $(this).addClass("xMasActive"); } }); }); </script> But it's showing all the images. What am I missing? (any ideas on making the code simpler are more than welcomed). Thanks for your help! Update: simplified HTML <div><img src="day21.png" which="21"/></a></div> <img id="bola21" class="calDate2" src="day21.png"/>

    Read the article

  • JavaScript - question regarding data structure

    - by orokusaki
    I'm trying to calculate somebody's bowel health based on a points system. I can edit the data structure, or logic in any way. I'm just trying to write a function and data structure to handle this ability. Pseudo calculator function: // Bowel health calculator var points = 0; If age is from 30 and 34: points += 1 If age is from 35 and 40: points += 2 If daily BMs is from 1 and 3: points -= 1 If daily BMs is from 4 and 6: points -= 2 return points; Pseudo data structure: var points_map = { age: { '30-34': 1, '35-40': 2 }, dbm: { '1-3': -1, '4-6': -2 } }; I have a full spreadsheet of data like this, and I am trying to write a DRY version of code and a DRY version of this data (ie, probably not a string for the '30-34', etc) in order to handle this sort of thing without a humongous number of switch statements.

    Read the article

  • c# how to get keydown and button click to do the same thing??

    - by myax
    I am new to C#.I am learning to make a calculator just like ms windows calculator.the buttons work when i click it, but I want the numpad to work too. Suppose the user types '0', it should be the same as if he clicked the 0 button on my gui. here is my button click event for 0. private void button0_Click(object sender, EventArgs e) { checkifequa(); textBox1.Text = textBox1.Text + "0"; } how do i get the keydown to work?

    Read the article

  • MSTest/NUnit Writing BDD style "Given, When, Then" tests

    - by Charlie
    I have been using MSpec to write my unit tests and really prefer the BDD style, I think it's a lot more readable. I'm now using Silverlight which MSpec doesn't support so I'm having to use MSTest but would still like to maintain a BDD style so am trying to work out a way to do this. Just to explain what I'm trying to acheive, here's how I'd write an MSpec test [Subject(typeof(Calculator))] public class when_I_add_two_numbers : with_calculator { Establish context = () => this.Calculator = new Calculator(); Because I_add_2_and_4 = () => this.Calculator.Add(2).Add(4); It should_display_6 = () => this.Calculator.Result.ShouldEqual(6); } public class with_calculator { protected static Calculator; } So with MSTest I would try to write the test like this (although you can see it won't work because I've put in 2 TestInitialize attributes, but you get what I'm trying to do..) [TestClass] public class when_I_add_two_numbers : with_calculator { [TestInitialize] public void GivenIHaveACalculator() { this.Calculator = new Calculator(); } [TestInitialize] public void WhenIAdd2And4() { this.Calculator.Add(2).Add(4); } [TestMethod] public void ThenItShouldDisplay6() { this.Calculator.Result.ShouldEqual(6); } } public class with_calculator { protected Calculator Calculator {get;set;} } Can anyone come up with some more elegant suggestions to write tests in this way with MSTest? Thanks

    Read the article

  • Allowing user to type only one "."

    - by Tartar
    I am trying to implement a simple javascript-html calculator. What i want to do is,typing only one '.' by the user. How can i control this ? Here is the code that i tried. I can already find the number of '.' but i'am confused now also this replaceAll function is not replacing '.' with empty string. String.prototype.replaceAll = function(search, replace) { //if replace is null, return original string otherwise it will //replace search string with 'undefined'. if(!replace) return this; return this.replace(new RegExp('[' + search + ']', 'g'), replace); }; function calculate(){ var value = document.calculator.text.value; var valueArray = value.split(""); var arrayLenght = valueArray.length; var character = "."; var charCount = 0; for(i=0;i<arrayLenght;i++){ if (valueArray[i]===character) { charCount += 1; } } if(charCount>1){ var newValue=value.replaceAll(".",""); alert(newValue); } }

    Read the article

  • floating point hex octal binary

    - by workinprogress
    Hi, I am working on a calculator that allows you to perform calculations past the decimal point in octal, hexadecimal, binary, and of course decimal. I am having trouble though finding a way to convert floating point decimal numbers to floating point hexadecimal, octal, binary and vice versa. The plan is to do all the math in decimal and then convert the result into the appropriate number system. Any help, ideas or examples would be appreciated. Thanks!

    Read the article

  • Decoding relationship between two numbers?

    - by Nimbuz
    Is there any way (or calculator) to determine the relationship between two numbers. For example on one the temporary event ID cards, the Unique ID is 20309825 but the barcode when decoded reads 8336902052. What could be the relationship between these numbers, if any? Thanks in advance for your help!

    Read the article

  • Help to calculate hours and minutes between two time periods in Excel 2007

    - by Mestika
    Hi, I’m working on a very simple timesheet for my work in Excel 2007 but have ran into trouble about calculate the hours and minutes between two time periods. I have a field: timestart which could be for example: 08:30 Then I have a field timestop which could be for example: 12:30 I can easy calculate the result myself which is 4 hours but how do I create a “total” table all the way down the cell that calculate the hours spend on each entry? I’ve tried to play around with the time settings but it just give me wrong numbers each time. Sincerely Mestika

    Read the article

  • Dividing with Gnu's bc

    - by Boldewyn
    I'm just starting with Gnu's bc and I'm stuck at the very beginning (very discouraging...). I want to divide two numbers and get a float as result: $bc bc 1.06.94 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 15/12 1 15.0/12.0 1 15.000000/12.000000 1 scale(15.00000) 5 The man page says, that division returns a number with the same scale as the initial values. Obviously this is either not true or I'm missing something. Googling hasn't brought up any new insights (besides that 'BC' can also stand for 'British Columbia'). Do you see my error? Better yet, do you know any good references/tutorials to bc?

    Read the article

  • google maps v3 distance

    - by Shane
    Trying to create a new version of the map functions seen here: http://www.daftlogic.com/projects-google-maps-distance-calculator.htm but using the v3 api. So far I am able to set markers on click and can draw the geodesic polyline. The issues I am currently running into are: Updating the poly-line on marker drag I'm pretty sure I have to put each marker in an array and do a for loop so that I can keep clicking and adding points that will add to the total distance. Properly displaying distance. I have created a jsfiddle: http://jsfiddle.net/wyZyS/ EDIT: I realize I have nothing calling the "update" function. I am trying to create the array for each marker currently. The calculation you see is converting meters to nautical miles.

    Read the article

  • How to implement a grapher in C#

    - by iansinke
    So I'm writing a graphing calculator. So far I have a semi-functional grapher, however, I'm having a hard time getting a good balance between accurate graphs and smooth looking curves. The current implementation (semi-pseudo-code) looks something like this: for (float i = GraphXMin; i <= GraphXMax; i++) { PointF P = new PointF(i, EvaluateFunction(Function, i) ListOfPoints.Add(P) } Graphics.DrawCurve(ListOfPoints) The problem with this is since it only adds a point at every integer value, graphs end up distorted when their turning points don't fall on integers (e.g. sin(x)^2). I tried incrementing i by something smaller (like 0.1), which works, but the graph looks very rough. I am using C# and GDI+. I have SmoothingMethod set to AntiAlias, so that's not the problem, as you can see from the first graph. Is there some sort of issue with drawing curves with a lot of points? Should the points perhaps be positioned exactly on pixels? I'm sure some of you have worked on something very similar before, so any suggestions? While you're at it, do you have any suggestions for graphing functions with asymptotes? e.g. 1/x^2 P.S. I'm not looking for a library that does all this - I want to write it myself.

    Read the article

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