# Search Results

• ### Control HUA YI Electrnic Power Supply

This program show you how to control, give set-point and getting feedback from Hua YI made Power Supplies

• ### fit a ellipse in Python given a set of points xi=(xi,yi)

##### - by Gianni
I am computing a series of index from a 2D points (x,y). One index is the ratio between minor and major axis. To fit the ellipse i am using the following post when i run these function the final results looks strange because the center and the axis length are not in scale with the 2D points center = [ 560415.53298363+0.j 6368878.84576771+0.j] angle of rotation = (-0.0528033467597-5.55111512313e-17j) axes = [0.00000000-557.21553487j 6817.76933256 +0.j] thanks in advance for help import numpy as np from numpy.linalg import eig, inv def fitEllipse(x,y): x = x[:,np.newaxis] y = y[:,np.newaxis] D = np.hstack((x*x, x*y, y*y, x, y, np.ones_like(x))) S = np.dot(D.T,D) C = np.zeros([6,6]) C[0,2] = C[2,0] = 2; C[1,1] = -1 E, V = eig(np.dot(inv(S), C)) n = np.argmax(np.abs(E)) a = V[:,n] return a def ellipse_center(a): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] num = b*b-a*c x0=(c*d-b*f)/num y0=(a*f-b*d)/num return np.array([x0,y0]) def ellipse_angle_of_rotation( a ): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] return 0.5*np.arctan(2*b/(a-c)) def ellipse_axis_length( a ): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] up = 2*(a*f*f+c*d*d+g*b*b-2*b*d*f-a*c*g) down1=(b*b-a*c)*( (c-a)*np.sqrt(1+4*b*b/((a-c)*(a-c)))-(c+a)) down2=(b*b-a*c)*( (a-c)*np.sqrt(1+4*b*b/((a-c)*(a-c)))-(c+a)) res1=np.sqrt(up/down1) res2=np.sqrt(up/down2) return np.array([res1, res2]) if __name__ == '__main__': points = [(560036.4495758876, 6362071.890493258), (560036.4495758876, 6362070.890493258), (560036.9495758876, 6362070.890493258), (560036.9495758876, 6362070.390493258), (560037.4495758876, 6362070.390493258), (560037.4495758876, 6362064.890493258), (560036.4495758876, 6362064.890493258), (560036.4495758876, 6362063.390493258), (560035.4495758876, 6362063.390493258), (560035.4495758876, 6362062.390493258), (560034.9495758876, 6362062.390493258), (560034.9495758876, 6362061.390493258), (560032.9495758876, 6362061.390493258), (560032.9495758876, 6362061.890493258), (560030.4495758876, 6362061.890493258), (560030.4495758876, 6362061.390493258), (560029.9495758876, 6362061.390493258), (560029.9495758876, 6362060.390493258), (560029.4495758876, 6362060.390493258), (560029.4495758876, 6362059.890493258), (560028.9495758876, 6362059.890493258), (560028.9495758876, 6362059.390493258), (560028.4495758876, 6362059.390493258), (560028.4495758876, 6362058.890493258), (560027.4495758876, 6362058.890493258), (560027.4495758876, 6362058.390493258), (560026.9495758876, 6362058.390493258), (560026.9495758876, 6362057.890493258), (560025.4495758876, 6362057.890493258), (560025.4495758876, 6362057.390493258), (560023.4495758876, 6362057.390493258), (560023.4495758876, 6362060.390493258), (560023.9495758876, 6362060.390493258), (560023.9495758876, 6362061.890493258), (560024.4495758876, 6362061.890493258), (560024.4495758876, 6362063.390493258), (560024.9495758876, 6362063.390493258), (560024.9495758876, 6362064.390493258), (560025.4495758876, 6362064.390493258), (560025.4495758876, 6362065.390493258), (560025.9495758876, 6362065.390493258), (560025.9495758876, 6362065.890493258), (560026.4495758876, 6362065.890493258), (560026.4495758876, 6362066.890493258), (560026.9495758876, 6362066.890493258), (560026.9495758876, 6362068.390493258), (560027.4495758876, 6362068.390493258), (560027.4495758876, 6362068.890493258), (560027.9495758876, 6362068.890493258), (560027.9495758876, 6362069.390493258), (560028.4495758876, 6362069.390493258), (560028.4495758876, 6362069.890493258), (560033.4495758876, 6362069.890493258), (560033.4495758876, 6362070.390493258), (560033.9495758876, 6362070.390493258), (560033.9495758876, 6362070.890493258), (560034.4495758876, 6362070.890493258), (560034.4495758876, 6362071.390493258), (560034.9495758876, 6362071.390493258), (560034.9495758876, 6362071.890493258), (560036.4495758876, 6362071.890493258)] a_points = np.array(points) x = a_points[:, 0] y = a_points[:, 1] from pylab import * plot(x,y) show() a = fitEllipse(x,y) center = ellipse_center(a) phi = ellipse_angle_of_rotation(a) axes = ellipse_axis_length(a) print "center = ", center print "angle of rotation = ", phi print "axes = ", axes from pylab import * plot(x,y) plot(center[0:1],center[1:], color = 'red') show() each vertex is a xi,y,i point plot of 2D point and center of fit ellipse

• ### Haskell: "how much" of a type should functions receive? and avoiding complete "reconstruction"

##### - by L01man
I've got these data types: data PointPlus = PointPlus { coords :: Point , velocity :: Vector } deriving (Eq) data BodyGeo = BodyGeo { pointPlus :: PointPlus , size :: Point } deriving (Eq) data Body = Body { geo :: BodyGeo , pict :: Color } deriving (Eq) It's the base datatype for characters, enemies, objects, etc. in my game (well, I just have two rectangles as the player and the ground right now :p). When a key, the characters moves right, left or jumps by changing its velocity. Moving is done by adding the velocity to the coords. Currently, it's written as follows: move (PointPlus (x, y) (xi, yi)) = PointPlus (x + xi, y + yi) (xi, yi) I'm just taking the PointPlus part of my Body and not the entire Body, otherwise it would be: move (Body (BodyGeo (PointPlus (x, y) (xi, yi)) wh) col) = (Body (BodyGeo (PointPlus (x + xi, y + yi) (xi, yi)) wh) col) Is the first version of move better? Anyway, if move only changes PointPlus, there must be another function that calls it inside a new Body. I explain: there's a function update which is called to update the game state; it is passed the current game state, a single Body for now, and returns the updated Body. update (Body (BodyGeo (PointPlus xy (xi, yi)) wh) pict) = (Body (BodyGeo (move (PointPlus xy (xi, yi))) wh) pict) That tickles me. Everything is kept the same within Body except the PointPlus. Is there a way to avoid this complete "reconstruction" by hand? Like in: update body = backInBody \$ move \$ pointPlus body Without having to define backInBody, of course.

• ### randomized quicksort: probability of two elements comparison?

##### - by bantu
I am reading "Probability and Computing" by M.Mitzenmacher, E.Upfal and I have problems understanding how the probability of comparison of two elements is calculated. Input: the list (y1,y2,...,YN) of numbers. We are looking for pivot element. Question: what is probability that two elements yi and yj (ji) will be compared? Answer (from book): yi and yj will be compared if either yi or yj will be selected as pivot in first draw from sequence (yi,yi+1,...,yj-1,yj). So the probablity is: 2/(y-i+1). The problem for me is initial claim: for example, picking up yi in the first draw from the whole list will cause the comparison with yj (and vice-versa) and the probability is 2/n. So, rather the "reverse" claim is true -- none of the (yi+1,...,yj-1) elements can be selected beforeyi or yj, but the "pool" size is not fixed (in first draw it is n for sure, but on the second it is smaller). Could someone please explain this, how the authors come up with such simplified conclusion? Thank you in advance

• ### Screen Capture Under Win7 of JOGL Applet

##### - by binarybug
Hi I'm trying to take a screen shot of an applet running inside a browser. The applet is using JOGL (OpenGL for Java) to display 3D models. (1) The screen shots always come out either black or white.The current solution uses the usual GDI calls. Screen shots of applets not running OpenGL are fine. A few examples of JOGL apps can be found here https://jogl-demos.dev.java.net/ (2) Another thing I'm trying to achieve is to get the scrollable area inside the screen shot as well. I found this code on the internet which works fine except for the 2 issues mentioned above. import win32gui as wg import win32ui as wu import win32con def copyBitMap(hWnd, fname): wg.SetForegroundWindow(hWnd) cWnd = wu.CreateWindowFromHandle(hWnd) rect = cWnd.GetClientRect() (x,y) = (rect[2] - rect[0], rect[3] - rect[1]) hsrccDc = wg.GetDC(hWnd) hdestcDc = wg.CreateCompatibleDC(hsrccDc) hdestcBm = wg.CreateCompatibleBitmap(hsrccDc, x, y) wg.SelectObject(hdestcDc, hdestcBm.handle) wg.BitBlt(hdestcDc, 0, 0, x, y, hsrccDc, rect[0], rect[1], win32con.SRCCOPY) destcDc = wu.CreateDCFromHandle(hdestcDc) bmp = wu.CreateBitmapFromHandle(hdestcBm.handle) bmp.SaveBitmapFile(destcDc, fname)

• ### What are the benefits of left outer join vs nested aggregate selects to find the newest rows in a table?

##### - by RenderIn
I'm doing: select * from mytable y where y.year = (select max(yi.year) from mytable yi where yi.person = y.person) Is that better or worse from a performance aspect than: select y.* from mytable y left outer join mytable y2 on y.year < y2.year and y.person = y2.person where y2.year is null The explain plan/anecdotal evidence is inconclusive so I am wondering if in general one is better than the other.

• ### How select the rest of the word in incremental search in Eclipse?

##### - by arberg
When in incremental search mode in Eclipse, is there a way to select the rest of the word? For example, suppose I want to find the word “handleReservationGranted”. I type Ctrl-f to enter incremental search mode, and start typing the letters “han”. Now suppose I have found the beginning of “handleReservationGranted”. In my search box I have “han”, but I would now like to be able to select the rest of the word, so that the search box contains “handleReservationGranted” instead of “han”. In Xemacs, I can type Ctrl-s, type “han”, and then type Ctrl-w. Now my search term is “handleReservationGranted”, and not “han”. So now if I press Ctrl-s, I find the next occurrence of “handleReservationGranted”. I frequently prefer the incremental search over the search dialog, as the search dialog takes too much space on my screen, and most annoying it frequently hides the found matches. I am using Eclipse Galileo (3.5.2). Ctrl-Shift-L gives me the list of possible shortcuts in the given context, but none seems to fit what I'm looking for.

• ### Dell Latitude E6520 overheating

##### - by Wu Yi Han
I'm a newcomer to Ubuntu 11.10. My laptop is a Dell Latitude E6520, Sandy Bridge platform. The system cooling fan is crazy all the time. I don't do any intensive tasks. I really hope my laptop doesn't become a mushroom cloud. I suppose there's no perfect way to solve this... Can I lower the CPU frequency? Jupiter 0.0.51 was installed (power save mode). Cooling worked in my Windows 7 system until I deleted it. (I won't go back to Windows 7.)

• ### Add logo background color to data returned by StackAuth sites route

##### - by Yi Jiang
Given that now with Stack Exchange 2.0 the logo of some of the sites, like Web Apps, AskUbuntu, Photography, Gaming and Pro Webmasters have non-white background, I think it will be best if the StackAuth sites route can include the preferred background color for those the logo of these sites. This is especially important for sites like Photography whose logo is unreadable if the traditional white is used. Edit: Here's an example of what I mean here: As you can see, the AskUbuntu logo text totally invisible against a white background.

##### - by Yi Wang
I am a research in University of California, Irvine (UCI). I am conducting a research on collaboration tool usage in Open Source development. Your answers will help us to develop new, powerful tools in future. The link of this survey is: http://edu.surveygizmo.com/s3/1035227/Attitude-and-Usage-of-Collaboration-Tools-in-Open-Source-Software-Development The survey only takes you 5-8 mins. thanks a lot for you help!

• ### Wine pollutes "Open With" application list

##### - by Yi Jiang
The dialog box in question here is the one you get with the context menu option "open with other applications". Wine seems to have inserted more than a dozen or so entries for each application I install, which makes it a pain to find the correct application: What can I do to remove the duplicates? Update: Neither of the two solutions really work. The bug is interesting, but the symptoms does not match my problem (I'm not having problem with uninstalling applications, but rather the things that are inserted after installing them), and with the other one, all references to the Wine application are removed, which actually makes the problem worse (although it may be an acceptable solution if nothing else can be found). So this is still an open question; any takers?

• ### manage 2 wireless device

##### - by yi.tang.uni
I erased Windows 7 and installed Ubuntu 12.04 on my Dell Latitude E4200. I an very happy with my choice but with little pity. I cannot use the wireless service in my university as the build-in device works unstable. I bought a USB wireless device, which solve the problem. However, the build-in device keep to sent me message about unable to connect, which waste laptop's cup & battery. The phsical bottom to turn off wireless affect both devices. So the question is: "How can I manually shut down wireless device?" There is another interest comes to my mind: "Does 2 wireless improve the overall internet usage if I run a high-internet-consuming program like BT ?" Thank for your time and energy.

• ### Calling Matlab's MLApp.MLAppClass.FEval from F#

##### - by Matthew
Matlab provides a COM interface that supports remote execution of arbitrary functions (and code snippets). In particular, it has an Feval method that calls a given Matlab function. The third parameter to this method, pvarArgOut, has COM type VARIANT*, and appears in the Visual Studio F# editor as an argument of type: pvarArgOut: byref<obj> The following code calls interp1, which in Matlab returns a matrix (i.e. 2D double array) result, as is normal for most Matlab functions. let matlab = new MLApp.MLAppClass() let vector_to_array2d (v : vector) = Array2D.init v.Length 1 (fun i j -> v.[i]) let interp1 (xs : vector) (ys : vector) (xi : vector) = let yi : obj = new obj() matlab.Feval("interp1", 1, ref yi, vector_to_array2d xs, vector_to_array2d ys, vector_to_array2d xi) yi :?> float[,] This code compiles fine, but when calling interp1, I get a COM exception: A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE)) I get the same error whether initialize yi with a new obj, a new Array2D, or null. How does F# translate VARIANT output arguments?

• ### Clearing System.Web.Cache

##### - by Han Cheng
1: System.Collections.IDictionaryEnumerator enumerator = context.Cache.GetEnumerator(); 2: while (enumerator.MoveNext()) 3: { 4: context.Cache.Remove(enumerator.Key.ToString()); 5: }

• ### Ubuntu stuck in low resolution after UNinstalling / disabling NVidia drivers

##### - by Han Cnx
Tried the Nvidia driver, installed using the Additional Drivers panel. Didn't like it much; the CPU seemed to overheat more and the brightness controls stopped working. Also selecting a second display is a pain using that horrible NVidia settings thing. So wanted to disabled it again.. problem is, UBuntu is then stuck in either 640x480 or 800x600 (second time I tried to install it back and then remove again). How can I get this back the way it was? The original Ubuntu drivers worked just fine, allowing me to run Unity and games properly. I tried a xserver-xorg reconfigure but this didn't do anything. (No xorg.conf file either). This is on a Lenovo Thinkpad T410i

• ### Picture lens doesn't find anything

##### - by Han Cnx
I get Facebook results, but nothing from my computer. If I open a terminal and use 'locate' then I can find stuff, but the picture lens is empty. Note that my picture files are on an NTFS partition. I have made a link named 'Pictures' in my home folder that points to the location where the picture files are. Again, this works with the 'locate' command and it also works for the Music lens, which is also a link in my home folder. It also (kinda) works for the Video lens, though it only wants to find videos I have opened, which seems not consistent with the other lenses. (and also not very useful this way)