Search Results

Search found 751 results on 31 pages for 'pi 2r'.

Page 16/31 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • accessing object variables in javascript

    - by user1452370
    So, I just started javascript and everything was working fine till i came to objects. This peace of code is supposed to create a bouncing ball in a html canvas with javascript but it doesn't work. var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext("2d"); //clear function clear() { ctx.clearRect(0, 0, canvas.width, canvas.height); } here is my ball object //ball var ball = { x: canvas.width / 2, getX: function() { return x; }, setX: function(a) { x = a; }, y: canvas.height / 2, getY: function() { return y; }, setY: function(a) { y = a; }, mx: 2, getMx: function() { return mx; }, my: 4, getMy: function() { return my; }, r: 10, getR: function() { return r; } }; code to draw my ball function drawBall() { ctx.beginPath(); ctx.arc(ball.getX, ball.getY, ball.getR, 0, Math.PI * 2, true); ctx.fillStyle = "#83F52C"; ctx.fill(); } function circle(x, y, r) { ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2, true); ctx.fillStyle = "#83F52C"; ctx.fill(); } //draws ball and updates x,y cords function draw() { clear(); drawBall(); if (ball.getX() + ball.getMx() >= canvas.width || ball.getX()+ ball.getMx() <= 0) { ball.setMx(-ball.getMx()); } if (ball.getY() + ball.getMy() >= canvas.height|| ball.getY()+ ball.getMy() <= 0) { ball.setMy(-ball.getMy()); } ball.setX(ball.getX() + ball.getMx()); ball.setY(ball.getY() + ball.getMy()); } set interval function init() { return setInterval(draw, 10); } init();

    Read the article

  • Inner angle between two lines

    - by ocell
    Hi folks, I have two lines: Line1 and Line2. Each line is defined by two points (P1L1(x1, y1), P2L1(x2, y2) and P1L1(x1, y1), P2L3(x2, y3)). I want to know the inner angle defined by these two lines. For do it I calculate the angle of each line with the abscissa: double theta1 = atan(m1) * (180.0 / PI); double theta2 = atan(m2) * (180.0 / PI); After to know the angle I calculate the following: double angle = abs(theta2 - theta1); The problem or doubt that I have is: sometimes I get the correct angle but sometimes I get the complementary angle (for me outer). How can I know when subtract 180º to know the inner angle? There is any algorithm better to do that? Because I tried some methods: dot product, following formula: result = (m1 - m2) / (1.0 + (m1 * m2)); But always I have the same problem; I never known when I have the outer angle or the inner angle! Thanks in advance for reading my trouble and for your time! Oscar.

    Read the article

  • Filling an Area in visual studio C#

    - by lajoo
    I'm drawing a circle in C# and i have divided it into some parts,i want to fill different parts with different colors,is there anyway to do this? and how?i tried using fillpie() but i couldn't get the arguments to work. here is the code: int r = 150; g.DrawEllipse(Pens.Black, 300 - r, 250 - r, 2 * r, 2 * r); if (p != 0) g.DrawLine(Pens.Black, 300, 250, 300 + r, 250); double sum; sum = 0.0; for (int j = 0; j < p; j++) sum += data[j].value; double angle; angle = 0.0; for (int i = 0; i < p; i++) { angle += (double)(data[i].value / sum) * 2.0 * Math.PI; textBox1.Text += sum.ToString() + " : " + angle.ToString() + ":" + Math.Cos(angle).ToString() + "\r\n"; g.DrawLine(Pens.Black, 300, 250, 300 + (int)(Math.Cos(angle) * r), 250 - (int)(Math.Sin(angle) * r)); //g.FillPie(Brushes.Black, 300-r , 250 - r, r, r ,(float)(angle),(float)(angle+ (data[i].value / sum) * 2.0 * Math.PI)); } this actually divides the circle into different parts,i don't know how to fill them the commented line is where i

    Read the article

  • Break a while loop without using If or Break

    - by Justin
    I need to create a program that uses while to find the volume of a cylinder. I need the while loop to break if the user inputs a negative value for the height. My code looks like this: double sentinel=1, h=1, v=0, r, count=0; // declares all variables needed final double PI=3.14159; boolean NotNegative=true; while(NotNegative){// && count==0){ // while both the height is positive AND the total times run is 0 System.out.print("Enter height (Use negative to exit): "); // has the user input the height h=Double.parseDouble(br.readLine()); sentinel=h; // save sentinel as the inputted height while(sentinel>0){ System.out.print("Enter radius: "); // have the user input the radius r=Double.parseDouble(br.readLine()); v=PI*(r*r)*h; // find the volume System.out.println("The volume is " + v); // print out the volume count++; // increase the count each time this runs NotNegative=true; sentinel=-1; } } Any help?

    Read the article

  • Silverlight 3 ArcSegment to always draw circle's

    - by kapaboo
    Hi everyone, Ok, my arcSegment must always draw Circle's. For this reason I calculate the Arc's Width with the following formula: arcXRadius = (4 * Math.Pow(height, 2) + Math.Pow(distanceArcPoints, 2)) / (8 * height); so Arcs.Size = (arcXRadius,height) But seems that the height is scaled down when drawn. I want to add a small Circle to the Arc's middle (highest point) so when you drag it it changes the arc Height but also changes the Width so it will remain a circle. Here's how I calculate the Circle's (highest) point: Point middlePoint = GetMiddlePoint(arcPointA,arcPointB); double arcYRadius = arcSegment.Size.Height; if (arcYRadius <= 0) return middlePoint; double angle = arcSegment.RotationAngle; Point ellinewPoint = new Point(); ellinewPoint.X = Math.Cos((angle + 90) * Math.PI / 180) * arcYRadius + middlePoint.X; ellinewPoint.Y = Math.Sin((angle + 90) * Math.PI / 180) * arcYRadius + middlePoint.Y; Until Arc's.Size.Height Property gets Closer to the Width my Circle is not at the right Point. So maybe someone can give me a hint or tell me what am I doing wrong. Cheers, kapaboo

    Read the article

  • Low Level Console Input

    - by Soulseekah
    I'm trying to send commands to to the input of a cmd.exe application using the low level read/write console functions. I have no trouble reading the text (scraping) using the ReadConsole...() and WriteConsole() functions after having attached to the process console, but I've not figured out how to write for example "dir" and have the console interpret it as a sent command. Here's a bit of my code: CreateProcess(NULL, "cmd.exe", NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); AttachConsole(pi.dwProcessId); strcpy(buffer, "dir"); WriteConsole(GetStdHandle(STD_INPUT_HANDLE), buffer, strlen(buffer), &charRead, NULL); STARTUPINFO attributes of the process are all set to zero, except, of course, the .cb attribute. Nothing changes on the screen, however I'm getting an Error 6: Invalid Handle returned from WriteConsole to STD_INPUT_HANDLE. If I write to (STD_OUTPUT_HANDLE) I do get my dir written on the screen, but nothing of course happens. I'm guessing SetConsoleMode() might be of help, but I've tried many mode combinations, nothing helped. I've also created a quick console application that waits for input (scanf()) and echoes back whatever goes in, didn't work. I've also tried typing into the scanf() promp and then peek into the input buffer using PeekConsoleInput(), returns 0, but the INPUT_RECORD array is empty. I'm aware that there is another way around this using WriteConsoleInput() to directly inject INPUT_RECORD structured events into the console, but this would be way too long, I'll have to send each keypress into it. I hope the question is clear. Please let me know if you need any further information. Thanks for your help.

    Read the article

  • Problem with generic list and extension method(C#3.0)

    - by Newbie
    I have an issue. I am making an extension class for a Collection and it is generic.. like public static class ListExtensions { public static ICollection<T> Search<T>(this ICollection<T> collection, string stringToSearch) { ICollection<T> t1=null; foreach (T t in collection) { Type k = t.GetType(); PropertyInfo pi = k.GetProperty("Name"); if (pi.GetValue(t,null).Equals(stringToSearch)) { t1.Add(t); } } return t1; } } But I cannot add items to t1 as it is declared null. Error: object reference not set to an instance of the object. I am calling the method like List<TestClass> listTC = new List<TestClass>(); listTC.Add(new TestClass { Name = "Ishu", Age = 21 }); listTC.Add(new TestClass { Name = "Vivek", Age = 40 }); listTC.Add(new TestClass { Name = "some one else", Age = 12 }); listTC.Search("Ishu"); And the test class is public class TestClass { public string Name { get; set; } public int Age { get; set; } } Using : (C#3.0) & Framework - 3.5 Thanks

    Read the article

  • rotating a circle in UIView?

    - by senthilmuthu
    HI, i want to draw a circle in DrawRect through context like pie chart(took from tutorial) thorugh UITouch? i have given the code as follows,how can i rotate ? any help please? define PI 3.14159265358979323846 define snapshot_start 360 define snapshot_finish 360 static inline float radians(double degrees) { return degrees * PI / 180; } - (void)drawRect:(CGRect)rect { // Drawing code CGRect parentViewBounds = self.bounds; CGFloat x = CGRectGetWidth(parentViewBounds)/2; CGFloat y = CGRectGetHeight(parentViewBounds)*0.55; // Get the graphics context and clear it CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextClearRect(ctx, rect); // define stroke color CGContextSetRGBStrokeColor(ctx, 1, 1, 1, 1.0); // define line width CGContextSetLineWidth(ctx, 4.0); // need some values to draw pie charts double snapshotCapacity =20; double rawCapacity = 100; double systemCapacity = 1; int offset = 5; double pie1_start = 315.0; double pie1_finish = snapshotCapacity *360.0/rawCapacity; double system_finish = systemCapacity*360.0/rawCapacity; CGContextSetFillColor(ctx, CGColorGetComponents( [[UIColor greenColor] CGColor])); CGContextMoveToPoint(ctx, x+2*offset, y); CGContextAddArc(ctx, x+2*offset, y, 100, radians(snapshot_start), radians(snapshot_start+snapshot_finish), 0); CGContextClosePath(ctx); CGContextFillPath(ctx); // system capacity CGContextSetFillColor(ctx, CGColorGetComponents( [[UIColor colorWithRed:15 green:165/255 blue:0 alpha:1 ] CGColor])); CGContextMoveToPoint(ctx, x+offset,y); CGContextAddArc(ctx, x+offset, y, 100, radians(snapshot_start+snapshot_finish+offset), radians(snapshot_start+snapshot_finish+system_finish), 0); CGContextClosePath(ctx); CGContextFillPath(ctx); /* data capacity */ CGContextSetFillColor(ctx, CGColorGetComponents( [[UIColor colorWithRed:99/255 green:184/255 blue:255/255 alpha:1 ] CGColor])); CGContextMoveToPoint(ctx, x, y); CGContextAddArc(ctx, x, y, 100, radians(snapshot_start+snapshot_finish+system_finish+offset), radians(snapshot_start), 0); CGContextClosePath(ctx); CGContextFillPath(ctx); }

    Read the article

  • Suggestions for a django db structure

    - by rh0dium
    Hi Say I have the unknown number of questions. For example: Is the sky blue [y/n] What date were your born on [date] What is pi [3.14] What is a large integ [100] Now each of these questions poses a different but very type specific answer (boolean, date, float, int). Natively django can happily deal with these in a model. class SkyModel(models.Model): question = models.CharField("Is the sky blue") answer = models.BooleanField(default=False) class BirthModel(models.Model): question = models.CharField("What date were your born on") answer = models.DateTimeField(default=today) class PiModel(models.Model) question = models.CharField("What is pi") answer = models.FloatField() But this has the obvious problem in that each question has a specific model - so if we need to add a question later I have to change the database. Yuck. So now I want to get fancy - How do a set up a model where by the answer type conversion happens automagically? ANSWER_TYPES = ( ('boolean', 'boolean'), ('date', 'date'), ('float', 'float'), ('int', 'int'), ('char', 'char'), ) class Questions(models.model): question = models.CharField(() answer = models.CharField() answer_type = models.CharField(choices = ANSWER_TYPES) default = models.CharField() So in theory this would do the following: When I build up my views I look at the type of answer and ensure that I only put in that value. But when I want to pull that answer back out it will return the data in the format specified by the answer_type. Example 3.14 comes back out as a float not as a str. How can I perform this sort of automagic transformation? Or can someone suggest a better way to do this? Thanks much!!

    Read the article

  • Problem with "moveable-only types" in VC++ 2010

    - by Luc Touraille
    I recently installed Visual Studio 2010 Professional RC to try it out and test the few C++0x features that are implemented in VC++ 2010. I instantiated a std::vector of std::unique_ptr, without any problems. However, when I try to populate it by passing temporaries to push_back, the compiler complains that the copy constructor of unique_ptr is private. I tried inserting an lvalue by moving it, and it works just fine. #include <utility> #include <vector> int main() { typedef std::unique_ptr<int> int_ptr; int_ptr pi(new int(1)); std::vector<int_ptr> vec; vec.push_back(std::move(pi)); // OK vec.push_back(int_ptr(new int(2)); // compiler error } As it turns out, the problem is neither unique_ptr nor vector::push_back but the way VC++ resolves overloads when dealing with rvalues, as demonstrated by the following code: struct MoveOnly { MoveOnly() {} MoveOnly(MoveOnly && other) {} private: MoveOnly(const MoveOnly & other); }; void acceptRValue(MoveOnly && mo) {} int main() { acceptRValue(MoveOnly()); // Compiler error } The compiler complains that the copy constructor is not accessible. If I make it public, the program compiles (even though the copy constructor is not defined). Did I misunderstand something about rvalue references, or is it a (possibly known) bug in VC++ 2010 implementation of this feature?

    Read the article

  • Optimally place a pie slice in a rectangle.

    - by Lisa
    Given a rectangle (w, h) and a pie slice with start angle and end angle, how can I place the slice optimally in the rectangle so that it fills the room best (from an optical point of view, not mathematically speaking)? I'm currently placing the pie slice's center in the center of the rectangle and use the half of the smaller of both rectangle sides as the radius. This leaves plenty of room for certain configurations. Examples to make clear what I'm after, based on the precondition that the slice is drawn like a unit circle: A start angle of 0 and an end angle of PI would lead to a filled lower half of the rectangle and an empty upper half. A good solution here would be to move the center up by 1/4*h. A start angle of 0 and an end angle of PI/2 would lead to a filled bottom right quarter of the rectangle. A good solution here would be to move the center point to the top left of the rectangle and to set the radius to the smaller of both rectangle sides. This is fairly easy for the cases I've sketched but it becomes complicated when the start and end angles are arbitrary. I am searching for an algorithm which determines center of the slice and radius in a way that fills the rectangle best. Pseudo code would be great since I'm not a big mathematician.

    Read the article

  • Adding class constraints to typeclass instance

    - by BleuM937
    I'm trying to implement the Cantor Pairing Function, as an instance of a generic Pair typeclass, as so: module Pair (Pair, CantorPair) where -- Pair interface class Pair p where pi :: a -> a -> p a k :: p a -> a l :: p a -> a -- Wrapper for typing newtype CantorPair a = P { unP :: a } -- Assume two functions with signatures: cantorPair :: Integral a => a -> a -> CantorPair a cantorUnpair :: Integral a => CantorPair a -> (a, a) -- I need to somehow add an Integral a constraint to this instance, -- but I can't work out how to do it. instance Pair CantorPair where pi = cantorPair k = fst . cantorUnpair l = snd . cantorUnpair How can I add the appropriate Integral constraint to the instance? I have a vague feeling I might need to modify the Pair interface itself, but not sure how to go about this.

    Read the article

  • Android: Scheduling application to start with repeating alarms not working

    - by vikramagain
    I get my Broadcast receiver to set a recurring alarm, to fire up a service. Unfortunately this does not result in the service being called repeatedly (based on logcat). I've experimented with different values for the time interval too. Can someone help? (I'm testing through Eclipse on Android 3.2 Motorola xoom) Below is the code for the Broadcast receiver. alarm = (AlarmManager) arg0.getSystemService(Context.ALARM_SERVICE); Intent intentUploadService = new Intent (arg0, com.vikramdhunta.UploaderService.class); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 3); PendingIntent pi = PendingIntent.getBroadcast(arg0, 0, intentUploadService , 0); alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 5, pi); Below is the code for the Service class public UploaderService() { super("UploaderService"); mycounterid = globalcounter++; } @Override protected void onHandleIntent(Intent intent) { synchronized(this) { try { for (int i = 1;i < 5;i++) { // doesn't do much right now.. but this should appear in logcat Log.i(TAG,"OK " + globalcounter++ + " uploading..." + System.currentTimeMillis()); } } catch(Exception e) { } } } @Override public void onCreate() { super.onCreate(); Log.d("TAG", "Service created."); } @Override public IBinder onBind(Intent arg0) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Starting upload service..." + mycounterid); return super.onStartCommand(intent,flags,startId); }

    Read the article

  • Efficient way to remove empty lists from lists without evaluating held expressions?

    - by Alexey Popkov
    In previous thread an efficient way to remove empty lists ({}) from lists was suggested: Replace[expr, x_List :> DeleteCases[x, {}], {0, Infinity}] Using the Trott-Strzebonski in-place evaluation technique this method can be generalized for working also with held expressions: f1[expr_] := Replace[expr, x_List :> With[{eval = DeleteCases[x, {}]}, eval /; True], {0, Infinity}] This solution is more efficient than the one based on ReplaceRepeated: f2[expr_] := expr //. {left___, {}, right___} :> {left, right} But it has one disadvantage: it evaluates held expressions if they are wrapped by List: In[20]:= f1[Hold[{{}, 1 + 1}]] Out[20]= Hold[{2}] So my question is: what is the most efficient way to remove all empty lists ({}) from lists without evaluating held expressions? The empty List[] object should be removed only if it is an element of another List itself. Here are some timings: In[76]:= expr = Tuples[Tuples[{{}, {}}, 3], 4]; First@Timing[#[expr]] & /@ {f1, f2, f3} pl = Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}]; First@Timing[#[pl]] & /@ {f1, f2, f3} Out[77]= {0.581, 0.901, 5.027} Out[78]= {0.12, 0.21, 0.18} Definitions: Clear[f1, f2, f3]; f3[expr_] := FixedPoint[ Function[e, Replace[e, {a___, {}, b___} :> {a, b}, {0, Infinity}]], expr]; f1[expr_] := Replace[expr, x_List :> With[{eval = DeleteCases[x, {}]}, eval /; True], {0, Infinity}]; f2[expr_] := expr //. {left___, {}, right___} :> {left, right};

    Read the article

  • Using MPI_Type_Vector and MPI_Gather, in C.

    - by Goloneg
    Hi, I am trying to multiply square matrices in parallele with MPI. I use a MPI_Type_vector to send square submatrixes (arrays of float) to the processes, so they can calculate subproducts. Then, for the next iterations, these submatrices are send to neighbours processes as MPI_Type_contiguous (the whole submatrix is sent). This part is working as expected, and local results are corrects. Then, I use MPI_Gather with the contiguous types to send all local results back to the root process. The problem is, the final matrix is build (obviously, by this method) line by line instead of submatrix by submatrix. I wrote an ugly procedure rearranging the final matrix, but I would like to know if there is a direct way of performing the "inverse" operation of sending MPI_Type_vectors (i.e., sending an array of values and directly arranging it in a subarray form in the receiving array). An example, to try and clarify my long text : A[16] and B[16] are 4x4 matrices to be multiplied ; C[16] will contain the result ; 4 processes are used (Pi with i from 0 to 3) : Pi gets two 2x2 submatrices : subAi[4] and subBi[4] ; their product is stored locally in subCi[4]. For instance, P0 gets : subA0[4] containing A[0], A[1], A[4] and A[5] ; subB0[4] containing B[0], B[1], B[4] and B[5]. After everything is calculed, root process gathers all subCi[4]. Then C[16] contains : [ subC0[0], subC0[1], subC0[2], subC0[3], subC1[0], subC1[1], subC1[2], subC1[3], subC2[0], subC2[1], subC2[2], subC2[3], subC3[0], subC3[1], subC3[2], subC3[3]] and I would like it to be : [ subC0[0], subC0[1], subC1[0], subC1[1], subC0[2], subC0[3], subC1[2], subC1[3], subC2[0], subC2[1], subC3[0], subC3[1], subC2[2], subC2[3], subC3[2], subC3[3]] without further operation. Does someone know a way ? Thanks for your advices.

    Read the article

  • The sign of zero with float2

    - by JackOLantern
    Consider the following code performing operations on complex numbers with C/C++'s float: float real_part = log(3.f); float imag_part = 0.f; float real_part2 = (imag_part)*(imag_part)-(real_part*real_part); float imag_part2 = (imag_part)*(real_part)+(real_part*imag_part); The result will be real_part2= -1.20695 imag_part2= 0 angle= 3.14159 where angle is the phase of the complex number and, in this case, is pi. Now consider the following code: float real_part = log(3.f); float imag_part = 0.f; float real_part2 = (-imag_part)*(-imag_part)-(real_part)*(real_part); float imag_part2 = (-imag_part)*(real_part)+(real_part)*(-imag_part); The result will be real_part2= -1.20695 imag_part2= 0 angle= -3.14159 The imaginary part of the result is -0 which makes the phase of the result be -pi. Although still accomplishing with the principal argument of a complex number and with the signed property of floating point's 0, this changes is a problem when one is defining functions of complex numbers. For example, if one is defining sqrt of a complex number by the de Moivre formula, this will change the sign of the imaginary part of the result to a wrong value. How to deal with this effect?

    Read the article

  • Groovy and XML: Not able to insert processing instruction

    - by rhellem
    Scenario Need to update some attributes in an existing XML-file. The file contains a XSL processing instruction, so when the XML is parsed and updated I need to add the instruction before writing it to a file again. Problem is - whatever I do - I'm not able to insert the processing instruction Based on the Java-example found at rgagnon.com I have created the code below Example code ## import groovy.xml.* def xml = '''|<something> | <Settings> | </Settings> |</something>'''.stripMargin() def document = DOMBuilder.parse( new StringReader( xml ) ) def pi = document.createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="Bp8DefaultView.xsl"'); document.insertBefore(pi, document.documentElement) println document.documentElement Creates output <?xml version="1.0" encoding="UTF-8"?> <something> <Settings> </Settings> </something> What I want <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Bp8DefaultView.xsl"?> <something> <Settings> </Settings> </something>

    Read the article

  • Sending an SMS in Android

    - by D4N14L
    Hey, I have been making an Android app which needs to send a text message. Here is the current code I have: public class getMessage extends Service { @Override public IBinder onBind(Intent intent) { return null; } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); client Phone = new client(); String[] msg = Phone.getMsg(user[0],user[1]); PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, getMessage.class), 0); SmsManager man = SmsManager.getDefault(); Log.e("GOT MESSAGE", msg[0]+ " : " +msg[1]); man.sendTextMessage(msg[0], null, msg[1], pi, null); Log.e("Message", "Sent the message?"); } Now, for some reason, the text message will not send using this code, and I'm not sure why. I was hoping that someone here could help me out in finding why this message won't send. No error is raised, nothing appears in the log (except for the log messages that I make myself in the code). Also, the manifest does have the correct tags. Suggestions?

    Read the article

  • Advance Query with Join

    - by user1462589
    I'm trying to convert a product table that contains all the detail of the product into separate tables in SQL. I've got everything done except for duplicated descriptor details. The problem I am having all the products have size/color/style/other that many other products contain. I want to only have one size or color descriptor for all the items and reuse the "ID" for all the product which I believe is a Parent key to the Product ID which is a ...Foreign Key. The only problem is that every descriptor would have multiple Foreign Keys assigned to it. So I was thinking on the fly just have it skip figuring out a Foreign Parent key for each descriptor and just check to see if that descriptor exist and if it does use its Key for the descriptor. Data Table PI Colo Sz OTHER 1 | Blue | 5 | Vintage 2 | Blue | 6 | Vintage 3 | Blac | 5 | Simple 4 | Blac | 6 | Simple =================================== Its destination table is this =================================== DI Description 1 | Blue 2 | Blac 3 | 5 4 | 6 6 | Vintage 7 | Simple ============================= Select Data.Table Unique.Data.Table.Colo Unique.Data.Table.Sz Unique.Data.Table.Other ======================================= Then the dual part of the questions after we create all the descriptors how to do a new query and assign the product ID to the descriptors. PI| DI 1 | 1 1 | 3 1 | 4 2 | 1 2 | 3 2 | 4 By figuring out how to do this I should be able to duplicate this pattern for all 300 + columns in the product. Some of these fields are 60+ characters large so its going to save a ton of space. Do I use a Array?

    Read the article

  • How to see if turbo boost is working on I7 860 CPU?

    - by Jan Derk
    I just build myself a new system with a Intel I7 860 CPU. When loading it using a single threaded application like Super PI, CPU-Z shows 2.933Ghz as speed. Now I understood that the I7 goes into turbo boost mode up to 3.46GHz for a single core. How can I check that? Is there a utility to monitor CPU speed per core?

    Read the article

  • OpenVPN not sending traffic to internet?

    - by coleifer
    I've set up openvpn on my pi and am running into a small issue. I can connect to the VPN server and ping it just fine, and I can also connect to other machines on my local network. However I am unable, when connected to the VPN, to reach the outside world (either by name lookup or IP). here are the details: On the server the tun0 interface: tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500 inet 10.8.0.1 netmask 255.255.255.255 destination 10.8.0.2 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 I can ping it just fine: # ping -c 3 10.8.0.1 PING 10.8.0.1 (10.8.0.1) 56(84) bytes of data. 64 bytes from 10.8.0.1: icmp_seq=1 ttl=64 time=0.159 ms 64 bytes from 10.8.0.1: icmp_seq=2 ttl=64 time=0.155 ms 64 bytes from 10.8.0.1: icmp_seq=3 ttl=64 time=0.156 ms --- 10.8.0.1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms Routing table # ip route show default via 192.168.1.1 dev eth0 metric 204 10.8.0.0/24 via 10.8.0.2 dev tun0 10.8.0.2 dev tun0 proto kernel scope link src 10.8.0.1 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.6 metric 204 I also have ip traffic forwarding: net.ipv4.ip_forward = 1 I do not have any custom iptables rules (that I'm aware of). On the client, I can connect to the VPN. Here is my tun0: tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500 inet 10.8.0.6 netmask 255.255.255.255 destination 10.8.0.5 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 21 bytes 1527 (1.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 And on the client I can ping it: sudo ping -c 3 10.8.0.6 PING 10.8.0.6 (10.8.0.6) 56(84) bytes of data. 64 bytes from 10.8.0.6: icmp_seq=1 ttl=64 time=0.035 ms 64 bytes from 10.8.0.6: icmp_seq=2 ttl=64 time=0.026 ms 64 bytes from 10.8.0.6: icmp_seq=3 ttl=64 time=0.032 ms --- 10.8.0.6 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.026/0.031/0.035/0.003 ms I can ssh from the client into another server on my LAN (192.168.1.x), however I cannot reach anything outside my LAN. Here's some of the server logs at the bottom of this gist: https://gist.github.com/coleifer/6ef95c3008f130249933/edit I am frankly out of ideas! I don't think it's my client because both my laptop and my phone (which has an openvpn client) exhibit the same behavior. I had OpenVPN installed on this pi before using debian and it worked, so I don't think it's my router but of course anything is possible.

    Read the article

  • How can I change the size of my SD card partition on os x 10.6.8 using gparted or disk utility?

    - by user1068636
    I"m running OS X 10.6.8 and I would like to use gparted to resize a partition on my SD card by following instructions on this page: http://mitchtech.net/easy-gui-install-re-partition-raspberry-pi-on-ubuntu/ However, it appears like gparted is suitable only for linux environment. I was wondering what alternatives do I have on os x to achieve increasing the size of the partition on my SD card? Would appreciate all / any advice.

    Read the article

  • Get a script to run at startup (linux)

    - by Dan Graves
    I am trying to get a simple script to run automatically at startup. A friend told me to do this but it did not work. Could someone take a look to see what it is missing? *(Also I am brand new to linux, so this is pretty foreign to me) Here is what I was told to do: In terminal sudo nano /etc/init.d/obabp.sh Then enter this text: #!/bin/bash sudo python /home/pi/gits/RPi-OBABP/src/obabp.py save file and then $ sudo chmod +x /etc/init.d/obabp.sh $ sudo shutdown -r now

    Read the article

  • How to find vector for the quaternion from X Y Z rotations

    - by can poyrazoglu
    I am creating a very simple project on OpenGL and I'm stuck with rotations. I am trying to rotate an object indepentdently in all 3 axes: X, Y, and Z. I've had sleepless nights due to the "gimbal lock" problem after rotating about one axis. I've then learned that quaternions would solve my problem. I've researched about quaternions and implementd it, but I havent't been able to convert my rotations to quaternions. For example, if I want to rotate around Z axis 90 degrees, I just create the {0,0,1} vector for my quaternion and rotate it around that axis 90 degrees using the code here: http://iphonedevelopment.blogspot.com/2009/06/opengl-es-from-ground-up-part-7_04.html (the most complicated matrix towards the bottom) That's ok for one vector, but, say, I first want to rotate 90 degrees around Z, then 90 degrees around X (just as an example). What vector do I need to pass in? How do I calculate that vector. I am not good with matrices and trigonometry (I know the basics and the general rules, but I'm just not a whiz) but I need to get this done. There are LOTS of tutorials about quaternions, but I seem to understand none (or they don't answer my question). I just need to learn to construct the vector for rotations around more than one axis combined. UPDATE: I've found this nice page about quaternions and decided to implement them this way: http://www.cprogramming.com/tutorial/3d/quaternions.html Here is my code for quaternion multiplication: void cube::quatmul(float* q1, float* q2, float* resultRef){ float w = q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3]; float x = q1[0]*q2[1] + q1[1]*q2[0] + q1[2]*q2[3] - q1[3]*q2[2]; float y = q1[0]*q2[2] - q1[1]*q2[3] + q1[2]*q2[0] + q1[3]*q2[1]; float z = q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1] + q1[3]*q2[0]; resultRef[0] = w; resultRef[1] = x; resultRef[2] = y; resultRef[3] = z; } Here is my code for applying a quaternion to my modelview matrix (I have a tmodelview variable that is my target modelview matrix): void cube::applyquat(){ float& x = quaternion[1]; float& y = quaternion[2]; float& z = quaternion[3]; float& w = quaternion[0]; float magnitude = sqrtf(w * w + x * x + y * y + z * z); if(magnitude == 0){ x = 1; w = y = z = 0; }else if(magnitude != 1){ x /= magnitude; y /= magnitude; z /= magnitude; w /= magnitude; } tmodelview[0] = 1 - (2 * y * y) - (2 * z * z); tmodelview[1] = 2 * x * y + 2 * w * z; tmodelview[2] = 2 * x * z - 2 * w * y; tmodelview[3] = 0; tmodelview[4] = 2 * x * y - 2 * w * z; tmodelview[5] = 1 - (2 * x * x) - (2 * z * z); tmodelview[6] = 2 * y * z - 2 * w * x; tmodelview[7] = 0; tmodelview[8] = 2 * x * z + 2 * w * y; tmodelview[9] = 2 * y * z + 2 * w * x; tmodelview[10] = 1 - (2 * x * x) - (2 * y * y); tmodelview[11] = 0; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadMatrixf(tmodelview); glMultMatrixf(modelview); glGetFloatv(GL_MODELVIEW_MATRIX, tmodelview); glPopMatrix(); } And my code for rotation (that I call externally), where quaternion is a class variable of the cube: void cube::rotatex(int angle){ float quat[4]; float ang = angle * PI / 180.0; quat[0] = cosf(ang / 2); quat[1] = sinf(ang/2); quat[2] = 0; quat[3] = 0; quatmul(quat, quaternion, quaternion); applyquat(); } void cube::rotatey(int angle){ float quat[4]; float ang = angle * PI / 180.0; quat[0] = cosf(ang / 2); quat[1] = 0; quat[2] = sinf(ang/2); quat[3] = 0; quatmul(quat, quaternion, quaternion); applyquat(); } void cube::rotatez(int angle){ float quat[4]; float ang = angle * PI / 180.0; quat[0] = cosf(ang / 2); quat[1] = 0; quat[2] = 0; quat[3] = sinf(ang/2); quatmul(quat, quaternion, quaternion); applyquat(); } I call, say rotatex, for 10-11 times for rotating only 1 degree, but my cube gets rotated almost 90 degrees after 10-11 times of 1 degree, which doesn't make sense. Also, after calling rotation functions in different axes, My cube gets skewed, gets 2 dimensional, and disappears (a column in modelview matrix becomes all zeros) irreversibly, which obviously shouldn't be happening with a correct implementation of the quaternions.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >