Search Results

Search found 444 results on 18 pages for 'equation'.

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

  • How to achieve interaction between GUI class with logic class

    - by volting
    Im new to GUI programming, and haven't done much OOP. Im working on a basic calculator app to help me learn GUI design and to brush up on OOP. I understand that anything GUI related should be kept seperate from the logic, but Im unsure how to implement interaction between logic an GUI classes when needed i.e. basically passing variables back and forth... Im using TKinter and when I pass a tkinter variable to my logic it only seems to hold the string PY_VAR0. def on_equal_btn_click(self): self.entryVariable.set(self.entryVariable.get() + "=") calculator = Calc(self.entryVariable) self.entryVariable.set(calculator.calculate()) Im sure that im probably doing something fundamentally wrong and probabaly really stupid, I spent a considerable amount of time experimenting (and searching for answers online) but Im getting no where. Any help would be appreciated. Thanks, V The Full Program (well just enough to show the structure..) import Tkinter class Gui(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.grid() self.create_widgets() """ grid config """ #self.grid_columnconfigure(0,weight=1,pad=0) self.resizable(False, False) def create_widgets(self): """row 0 of grid""" """Create Text Entry Box""" self.entryVariable = Tkinter.StringVar() self.entry = Tkinter.Entry(self,width=30,textvariable=self.entryVariable) self.entry.grid(column=0,row=0, columnspan = 3 ) self.entry.bind("<Return>", self.on_press_enter) """create equal button""" equal_btn = Tkinter.Button(self,text="=",width=4,command=self.on_equal_btn_click) equal_btn.grid(column=3, row=0) """row 1 of grid""" """create number 1 button""" number1_btn = Tkinter.Button(self,text="1",width=8,command=self.on_number1_btn_click) number1_btn.grid(column=0, row=1) . . . def on_equal_btn_click(self): self.entryVariable.set(self.entryVariable.get() + "=") calculator = Calc(self.entryVariable) self.entryVariable.set(calculator.calculate()) class Calc(): def __init__(self, equation): self.equation = equation def calculate(self): #TODO: parse string and calculate... return self.equation if __name__ == "__main__": app = Gui(None) app.title('Calculator') app.mainloop()

    Read the article

  • Are there real world applications where the use of prefix versus postfix operators matters?

    - by Kenneth
    In college it is taught how you can do math problems which use the ++ or -- operators on some variable referenced in the equation such that the result of the equation would yield different results if you switched the operator from postfix to prefix or vice versa. Are there any real world applications of using postfix or prefix operator where it makes a difference as to which you use? It doesn't seem to me (maybe I just don't have enough experience yet in programming) that there really is much use to having the different operators if it only applies in math equations. EDIT: Suggestions so far include: function calls //f(++x) != f(x++) loop comparison //while (++i < MAX) != while (i++ < MAX)

    Read the article

  • Infinite detail inside Perlin noise procedural mapping

    - by Dave Jellison
    I am very new to game development but I was able to scour the internet to figure out Perlin noise enough to implement a very simple 2D tile infinite procedural world. Here's the question and it's more conceptual than code-based in answer, I think. I understand the concept of "I plug in (x, y) and get back from Perlin noise p" (I'll call it p). P will always be the same value for the same (x, y) (as long as the Perlin algorithm parameters haven't changed, like altering number of octaves, et cetera). What I want to do is be able to zoom into a square and be able to generate smaller squares inside of the already generated overhead tile of terrain. Let's say I have a jungle tile for overhead terrain but I want to zoom in and maybe see a small river tile that would only be a creek and not large enough to be a full "big tile" of water in the overhead. Of course, I want the same net effect as a Perlin equation inside a Perlin equation if that makes sense? (aka. I want two people playing the game with the same settings to get the same terrain and details every time). I can conceptually wrap my head around the large tile being based on an "zoomed out" coordinate leaving enough room to drill into but this approach doesn't make sense in my head (maybe I'm wrong). I'm guessing with this approach my overhead terrain would lose all of the cohesiveness delivered by the Perlin. Imagine I calculate (0, 0) as overhead tile 1 and then to the east of that I plug in (50, 0). OK, great, I now have 49 pixels of detail I could then "drill down" into. The issue I have in my head with this approach (without attempting it) is that there's no guarantee from my Perlin noise that (0,0) would be a good neighbor to (50,0) as they could have wildly different "elevations" or p/resultant values returning from the Perlin equation when I generate the overhead map. I think I can conceive of using the Perlin noise for the overhead tile to then reuse the p value as a seed for the "detail" level of noise once I zoom in. That would ensure my detail Perlin is always the same configuration for (0,0), (1,0), etc. ad nauseam but I'm not sure if there are better approaches out there or if this is a sound approach at all.

    Read the article

  • 2D Car Simulation with Throttle Linear Physics

    - by James
    I'm trying to make a simulation game for an automatic cruise control system. The system simulates a car on varying inclinations and throttle speeds. I've coded up to the car physics but these do note make sense. The dynamics of the simulation are specified as follows: a = V' - V T = (k1)V + ?(k2) + ma V' = (1 - (k1 / m) V) + T - ( k2 / m) * ? Where T = throttle position k1 = viscous friction V = speed V' = next speed ? = angle of incline k2 = m g sin ? a = acceleration m = mass Notice that the angle of incline in the equation is not chopped up by sin or cos. Even the equation for acceleration isn't right. Can anyone correct them or am I misinterpreting the physics?

    Read the article

  • Find angle for projectile to meet target in parabolic arc

    - by TheBroodian
    I'm making a thing that launches projectiles in 2D. Its projectiles are fired with a set initial velocity, and are only affected by gravity. Assuming that its target is within range, and that there aren't any obstacles, how would my thing find the appropriate angle at which to launch its projectile (in radians)? The equation for this is found here: Wikipedia: Angle Required to Hit Coordinate Sadly, I'm not a physicist (a.k.a. can't read smart people math) and am having a hard time reading its breakdown. If not only for the sake of anybody else that might read this other than myself, would anybody be kind enough to break the equation down into baby words please?

    Read the article

  • Confusion about Rotation matrices from Euler Angles

    - by xEnOn
    I am trying to learn more about Euler Angles so as to help myself in understanding how I can control my camera better in the game. I came across the following formula that converts Euler Angles to rotation matrices: In the equation, I could see that the first matrix from the left is the rotation matrix about x-axis, the second is about y-axis and the third is about z-axis. From my understanding about ordinary matrix transformations, the later transformation is always applied to the right hand side. And if I'm right about this, then the above equation should have a rotation order starting from rotating about z-axis, y-axis, then finally x-axis. But, from the symbols it seems that the rotation order start rotating about x-axis, then y-axis, then finally z-axis. What should the actual order of the rotation be? Also, I am confuse about if the input vector, in this case, would be a row vector on the left, or a column vector on the right?

    Read the article

  • Convert latitude and longitude into northern and eastings

    - by Rippo
    Hi I have the following UK postcode dy8 3xt and know that the latitude and longitude is:- 52.190108 -2.517266 I also know that the Eastings, Northings for the postcode is:- 389490 283880 However I am struggling to find the equation that converts lat/long to northings and Eastings, I would prefer to have the equation in both in jScript and c# (I am being greedy)! Can anyone help?

    Read the article

  • Free Optimization Library in C#

    - by Ngu Soon Hui
    Is there any optimization library in C#? I have to optimize a complicated equation in excel, for this equation there are a few coefficients. And I have to optimize them according to a fitness function that I define. So I wonder whether there is such a library that does what I need?

    Read the article

  • Variable Operators in PHP

    - by BenTheDesigner
    Given this example, how would I return the result of the equation rather than the equation itself as a string? $operator = '+'; foreach($resultSet as $item){ $result = $item[$this->orderField] . $operator . 1; echo $result; }

    Read the article

  • recurrence maths

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

    Read the article

  • Netlogo programming question - is it possible to put balanced chemical equations in a model?

    - by user286190
    hi I was wondering if it was possible to put balanced chemical equations, and if possible including state symbols, in the existing netlogo model that i am using, i havenot seen any examples in the models library so was not sure if it was possible. I wanted the model to be able to allow the user to input a balanced chemical equilibrium equation, or the model displays the the equation so then the user can select from them if they do not want to enter their own any help will be greatly appreciated thanks for example ethane + oxygen -- carbon dioxide + steam C2H6 + O2 -- CO2 + H2O

    Read the article

  • Matlap Simulation

    - by iva123
    I have to make a simulation for Aircraft Cabin Pressure in Mathlap. But I could not find any characteristic equation on the web. Does anyone know where to start a characterisctic equation for matlap or can anyone suuggest me a book for it ?

    Read the article

  • Matlab Simulation

    - by iva123
    I have to make a simulation for Aircraft Cabin Pressure in Matlab. But I could not find any characteristic equation on the web. Does anyone know where to start a characteristic equation for Matlab or can anyone suggest a book for it ?

    Read the article

  • trouble in using flalign (LaTeX)

    - by Jorge
    I am trying to put 3 equations with "=" signs aligned but also left aligned. I tried the following: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{flalign*} RPC &= A+B\tilde{f} +C x &\ A &= a+\eta &\ E &= cte & \end{flalign*} \end{document} With this I get the stuff in the left and the "=" signs aligned. However, I also need A (in the second equation) and E (in the third equation) to be aligned to the R (in the first one) Does anyone know how to get it? thanks

    Read the article

  • validating html files with latex commands

    - by robezy
    I'm using latex commands in my html code. When I validate the at w3c validator, it is giving me inavlid markup message. Line 105, Column 31: non SGML character number 12 \begin{equation}(x^{2})^{4+(frac{1}{5})}\end{equation} Is there a way to pass validation? Can I ignore this error?

    Read the article

  • Solving Diophantine Equations Using Python

    - by HARSHITH
    In mathematics, a Diophantine equation (named for Diophantus of Alexandria, a third century Greek mathematician) is a polynomial equation where the variables can only take on integer values. Although you may not realize it, you have seen Diophantine equations before: one of the most famous Diophantine equations is: We are not certain that McDonald's knows about Diophantine equations (actually we doubt that they do), but they use them! McDonald's sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 nuggets, since no non- negative integer combination of 6's, 9's and 20's adds up to 16. To determine if it is possible to buy exactly n McNuggets, one has to solve a Diophantine equation: find non-negative integer values of a, b, and c, such that 6a + 9b + 20c = n. Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n): "Largest number of McNuggets that cannot be bought in exact quantity: n"

    Read the article

  • Reverse-projection 2D points into 3D

    - by ehsan baghaki
    Suppose we have a 3d Space with a plane on it with an arbitary equation : ax+by+cz+d=0 now suppose that we pick 3 random points on that plane: (x0,y0,z0) (x1,y1,z1) (x1,y1,z1) now i have a different point of view(camera) for this plane. i mean i have a different camera that will look at this plane from a different point of view. From that camera point of view these points have different locations. for example (x0,y0,z0) will be (x0',y0') and (x1,y1,z1) will be (x1',y1') and (x2,y2,z2) will be (x2',y2') from the new camera point of view. So here is my a little hard question! I want to pick a point for example (X,Y) from the new camera point of view and tell where it will be on that plane. All i know is that 3 points and their locations on 3d space and their projection locations on the new camera view. Do you know the coefficients of the plane-equation and the camera positions (along with the projection), or do you only have the six points? - Nils i know the location of first 3 points. therefore we can calculate the coefficients of the plane. so we know exactly where the plane is from (0,0,0) point of view. and then we have the camera that can only see the points! So the only thing that camera sees is 3 points and also it knows their locations in 3d space (and for sure their locations on 2d camera view plane). and after all i want to look at camera view, pick a point (for example (x1,y1)) and tell where is that point on that plane. (for sure this (X,Y,Z) point should fit on the plane equation). Also i know nothing about the camera location.

    Read the article

  • Finding X on Excel scatter plot/trend line

    - by Wilka
    If I have some data in an scatter plot in Excel, e.g. X Y 1 10 2 20 3 30 4 40 5 50 and I want to find the Y value for X = 10, or X=3.5, or whatever (obviously this is a simplified example) I've been doing the following: Add a trend-line to the scatter plot data Format the trend-line to one that fits the data (linear in this case) Display the equation for the trend-line on the chart Type the equation into an empty cell, replacing x with a cell reference. E.g. "=10*A1" then put my X value into the cell A1 Is there a better way of doing this with Excel? It's quite a few steps, and fairly repetitive. Or maybe Excel is just a poor choice of application for doing this? (I'm using Excel 2007)

    Read the article

  • Guidance in naming awkward objects?

    - by GlenH7
    I'm modeling a chemical system, and I'm having problems with naming my objects within an enum. I'm not sure if I should use: the atomic formula the chemical name an abbreviated chemical name. For example, sulfuric acid is H2SO4 and hydrochloric acid is HCl. With those two, I would probably just use the atomic formula as they are reasonably common. However, I have others like sodium hexafluorosilicate which is Na2SiF6. In that example, the atomic formula isn't as obvious (to me) but the chemical name is hideously long: myEnum.SodiumHexaFluoroSilicate. I'm not sure how I would be able to safely come up with an abbreviated chemical name that would have a consistent naming pattern. From a maintenance point of view, which of the options would you prefer to see and why? Audience for the code will be just programmers, not chemists. If that guides the particulars: I'm using C#; I'm starting with 10 - 20 compounds and would have at most 100 compounds. The enum is to facilitate common calculations - the equation is the same for all compounds but you insert a property of the compound to complete the equation.

    Read the article

  • Guidance in naming awkward domain-specific objects?

    - by GlenH7
    I'm modeling a chemical system, and I'm having problems with naming my objects within an enum. I'm not sure if I should use: the atomic formula the chemical name an abbreviated chemical name. For example, sulfuric acid is H2SO4 and hydrochloric acid is HCl. With those two, I would probably just use the atomic formula as they are reasonably common. However, I have others like sodium hexafluorosilicate which is Na2SiF6. In that example, the atomic formula isn't as obvious (to me) but the chemical name is hideously long: myEnum.SodiumHexaFluoroSilicate. I'm not sure how I would be able to safely come up with an abbreviated chemical name that would have a consistent naming pattern. From a maintenance point of view, which of the options would you prefer to see and why? Some details from comments on this question: Audience for the code will be just programmers, not chemists. I'm using C#, but I think this question is more interesting when ignoring the implementation language I'm starting with 10 - 20 compounds and would have at most 100 compounds. The enum is to facilitate common calculations - the equation is the same for all compounds but you insert a property of the compound to complete the equation. For example, Molar mass (in g/mol) is used when calculating the number of moles from a mass (in grams) of the compound. Another example of a common calculation is the Ideal Gas Law and its use of the Specific Gas Constant

    Read the article

  • What is the simplest way to interpolate and lookup in an x,y table in excel?

    - by dassouki
    I would like to do a lookup and interpolation based on x, y data for the following table. I'd like the equation to be as simple as possible to reduce the amount of possible errors. The full table is about 50 rows x 30 columns. I have about 20 of those tables. Here is an extract from one: A B C D 1 0.1 0.2 0.3 2 2.4 450 300 50 3 2.3 500 375 52 4 2.1 550 475 55 5 1.8 600 600 60 For example, the equation should find the value for x = 2.27 and y = 0.15

    Read the article

  • HTML5 Canvas Converting between cartesian and isometric coordinates

    - by Amir
    I'm having issues wrapping my head around the Cartesian to Isometric coordinate conversion in HTML5 canvas. As I understand it, the process is two fold: (1) Scale down the y-axis by 0.5, i.e. ctx.scale(1,0.5); or ctx.setTransform(1,0,0,0.5,0,0); This supposedly produces the following matrix: [x; y] x [1, 0; 0, 0.5] (2) Rotate the context by 45 degrees, i.e. ctx.rotate(Math.PI/4); This should produce the following matrix: [x; y] x [cos(45), -sin(45); sin(45), cos(45)] This (somehow) results in the final matrix of ctx.setTransform(2,-1,1,0.5,0,0); which I cannot seem to understand... How is this matrix derived? I cannot seem to produce this matrix by multiplying the scaling and rotation matrices produced earlier... Also, if I write out the equation for the final transformation matrix, I get: newX = 2x + y newY = -x + y/2 But this doesn't seem to be correct. For example, the following code draws an isometric tile at cartesian coordinates (500, 100). ctx.setTransform(2,-1,1,0.5,0,0); ctx.fillRect(500, 100, width*2, height); When I check the result on the screen, the actual coordinates are (285, 215) which do not satisfy the equations I produced earlier... So what is going on here? I would be very grateful if you could: (1) Help me understand how the final isometric transformation matrix is derived; (2) Help me produce the correct equation for finding the on-screen coordinates of an isometric projection. Many thanks and kind regards

    Read the article

  • How do I force ode45 to take steps of exactly 0.01 on the T axis?

    - by Gravitas
    I'm using Matlab to solve a differential equation. I want to force ode45 to take constant steps, so it always increments 0.01 on the T axis while solving the equation. How do I do this? ode45 is consistently taking optimized, random steps, and I can't seem to work out how to make it take consistent, small steps of 0.01. Here is the code: options= odeset('Reltol',0.001,'Stats','on'); %figure(1); %clf; init=[xo yo zo]'; tspan=[to tf]; %tspan = t0:0.01:tf; [T,Y]=ode45(name,tspan,init,options);

    Read the article

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