Search Results

Search found 440 results on 18 pages for 'abs'.

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

  • How to edit files on the users file system from my web server?

    - by Abs
    Hello all, I am really looking for implementation advice as I have entered a new realm that I am not familiar with. At the simplest level, I would like to find a way that I can read/write to a users machine from my web server. For this to work, I think I will have to install some sort of "plugin" on the users machine which can receive (or poll?) the server for instructions. The above is the line of thought that I currently have, maybe using JAVA to do this. This needs to work on Linux, Mac and Windows OS. I am really looking for advice on the above, is it a good idea? Is there a better way of doing this? Is there something out there already that I can build on top of? I really appreciate all input and advice as this is something I have not done before. Thanks all

    Read the article

  • CodeIgniter and Your Own Scripts

    - by Abs
    Hello all, I have found a class I would like to use to get bookmarks from a users delicious account. Here is how it is used. The problem I am having is, should I be turning this into a Codeigniter library? Can I not use it on its own as this is self contained? I am guessing I am asking for the best practice here. Thanks all for any help

    Read the article

  • Works in Firefox but not IE

    - by Abs
    Hello all, I make use of the following to find a string in a particular element, if it exists, tick a checkbox. This works great on Firefox but not internet explorer (8). I am having trouble finding why. $.fn.searchString = function(str) { return this.filter('*:contains("' + str + '")'); }; var myID = $('div').searchString(files_array[i].substr(-4)); alert(myID);//[object object] alert(myID.children());//[object object] myID.children().attr('checked', true);//does not tick checkbox alert(myID.children().attr('checked'));//undefined Does IE not like the children() function? Thanks all for any help

    Read the article

  • JQuery html function on a td

    - by Abs
    Hello all, I am trying to place some html within a td that has an id but this doesn't seem to work. Can JQuery not put html in a td by using its id as a selector?? I do this: $('#total_match').html("<b>Test</b>"); Here is the td: <td id="total_match"></td> No errors occur and nothing appears in the TD - I view the source to confirm. I appreciate any help.

    Read the article

  • DOMDocument::load in PHP 5

    - by Abs
    Hello all, I open a 10MB+ XML file several times in my script in different functions: $dom = DOMDocument::load( $file ) or die('couldnt open'); 1) Is the above the old style of loading a document? I am using PHP 5. Oppening it statically? 2) Do I need to close the loading of the XML file, if possible? I suspect its causing memory problems because I loop through the nodes of the XML file several thousand times and sometimes my script just ends abruptly. Thanks all for any help

    Read the article

  • How to convert ISampleGrabber::BufferCB's buffer to a bitmap

    - by user2509919
    I am trying to use the ISampleGrabberCB::BufferCB to convert the current frame to bitmap using the following code: int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr buffer, int bufferLength) { try { Form1 form1 = new Form1("", "", ""); if (pictureReady == null) { Debug.Assert(bufferLength == Math.Abs(pitch) * videoHeight, "Wrong Buffer Length"); } Debug.Assert(imageBuffer != IntPtr.Zero, "Remove Buffer"); Bitmap bitmapOfCurrentFrame = new Bitmap(width, height, capturePitch, PixelFormat.Format24bppRgb, buffer); MessageBox.Show("Works"); form1.changepicturebox3(bitmapOfCurrentFrame); pictureReady.Set(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return 0; } However this does not seem to be working. Additionally it seems to call this function when i press a button which runs the following code: public IntPtr getFrame() { int hr; try { pictureReady.Reset(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } imageBuffer = Marshal.AllocCoTaskMem(Math.Abs(pitch) * videoHeight); try { gotFrame = true; if (videoControl != null) { hr = videoControl.SetMode(stillPin, VideoControlFlags.Trigger); DsError.ThrowExceptionForHR(hr); } if (!pictureReady.WaitOne(9000, false)) { throw new Exception("Timeout waiting to get picture"); } } catch { Marshal.FreeCoTaskMem(imageBuffer); imageBuffer = IntPtr.Zero; } return imageBuffer; } Once this code is ran I get a message box which shows 'Works' thus meaning my BufferCB must of been called however does not update my picture box with the current image. Is the BufferCB not called after every new frame? If so why do I not recieve the 'Works' message box? Finally is it possible to convert every new frame into a bitmap (this is used for later processing) using BufferCB and if so how? Edited code: int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr buffer, int bufferLength) { Debug.Assert(bufferLength == Math.Abs(pitch) * videoHeight, "Wrong Buffer Length"); Debug.Assert(imageBuffer != IntPtr.Zero, "Remove Buffer"); CopyMemory(imageBuffer, buffer, bufferLength); Decode(buffer); return 0; } public Image Decode(IntPtr imageData) { var bitmap = new Bitmap(width, height, pitch, PixelFormat.Format24bppRgb, imageBuffer); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); Form1 form1 = new Form1("", "", ""); form1.changepicturebox3(bitmap); bitmap.Save("C:\\Users\\...\\Desktop\\A2 Project\\barcode.jpg"); return bitmap; } Button code: public void getFrameFromWebcam() { if (iPtr != IntPtr.Zero) { Marshal.FreeCoTaskMem(iPtr); iPtr = IntPtr.Zero; } //Get Image iPtr = sampleGrabberCallBack.getFrame(); Bitmap bitmapOfFrame = new Bitmap(sampleGrabberCallBack.width, sampleGrabberCallBack.height, sampleGrabberCallBack.capturePitch, PixelFormat.Format24bppRgb, iPtr); bitmapOfFrame.RotateFlip(RotateFlipType.RotateNoneFlipY); barcodeReader(bitmapOfFrame); } public IntPtr getFrame() { int hr; try { pictureReady.Reset(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } imageBuffer = Marshal.AllocCoTaskMem(Math.Abs(pitch) * videoHeight); try { gotFrame = true; if (videoControl != null) { hr = videoControl.SetMode(stillPin, VideoControlFlags.Trigger); DsError.ThrowExceptionForHR(hr); } if (!pictureReady.WaitOne(9000, false)) { throw new Exception("Timeout waiting to get picture"); } } catch { Marshal.FreeCoTaskMem(imageBuffer); imageBuffer = IntPtr.Zero; } return imageBuffer; } I also still need to press the button to run the BufferCB Thanks for reading.

    Read the article

  • 2D character controller in unity (trying to get old-school platformers back)

    - by Notbad
    This days I'm trying to create a 2D character controller with unity (using phisics). I'm fairly new to physic engines and it is really hard to get the control feel I'm looking for. I would be really happy if anyone could suggest solution for a problem I'm finding: This is my FixedUpdate right now: public void FixedUpdate() { Vector3 v=new Vector3(0,-10000*Time.fixedDeltaTime,0); _body.AddForce(v); v.y=0; if(state(MovementState.Left)) { v.x=-_walkSpeed*Time.fixedDeltaTime+v.x; if(Mathf.Abs(v.x)>_maxWalkSpeed) v.x=-_maxWalkSpeed; } else if(state(MovementState.Right)) { v.x= _walkSpeed*Time.fixedDeltaTime+v.x; if(Mathf.Abs(v.x)>_maxWalkSpeed) v.x=_maxWalkSpeed; } _body.velocity=v; Debug.Log("Velocity: "+_body.velocity); } I'm trying here to just move the rigid body applying a gravity and a linear force for left and right. I have setup a physic material that makes no bouncing and 0 friction when moving and 1 friction with stand still. The main problem is that I have colliders with slopes and the velocity changes from going up (slower) , going down the slope (faster) and walk on a straight collider (normal). How could this be fixed? As you see I'm applying allways same velocity for x axis. For the player I have it setup with a sphere at feet position that is the rigidbody I'm applying forces to. Any other tip that could make my life easier with this are welcomed :). P.D. While coming home I have noticed I could solve this applying a constant force parallel to the surface the player is walking, but don't know if it is best method.

    Read the article

  • Use depth bias for shadows in deferred shading

    - by cubrman
    We are building a deferred shading engine and we have a problem with shadows. To add shadows we use two maps: the first one stores the depth of the scene captured by the player's camera and the second one stores the depth of the scene captured by the light's camera. We then ran a shader that analyzes the two maps and outputs the third one with the ready shadow areas for the current frame. The problem we face is a classic one: Self-Shadowing: A standard way to solve this is to use the slope-scale depth bias and depth offsets, however as we are doing things in a deferred way we cannot employ this algorithm. Any attempts to set depth bias when capturing light's view depth produced no or unsatisfying results. So here is my question: MSDN article has a convoluted explanation of the slope-scale: bias = (m × SlopeScaleDepthBias) + DepthBias Where m is the maximum depth slope of the triangle being rendered, defined as: m = max( abs(delta z / delta x), abs(delta z / delta y) ) Could you explain how I can implement this algorithm manually in a shader? Maybe there are better ways to fix this problem for deferred shadows?

    Read the article

  • Finding direction of travel in a world with wrapped edges

    - by crazy
    I need to find the shortest distance direction from one point in my 2D world to another point where the edges are wrapped (like asteroids etc). I know how to find the shortest distance but am struggling to find which direction it's in. The shortest distance is given by: int rows = MapY; int cols = MapX; int d1 = abs(S.Y - T.Y); int d2 = abs(S.X - T.X); int dr = min(d1, rows-d1); int dc = min(d2, cols-d2); double dist = sqrt((double)(dr*dr + dc*dc)); Example of the world : : T : :--------------:--------- : : : S : : : : : : T : : : :--------------: In the diagram the edges are shown with : and -. I've shown a wrapped repeat of the world at the top right too. I want to find the direction in degrees from S to T. So the shortest distance is to the top right repeat of T. but how do I calculate the direction in degreed from S to the repeated T in the top right? I know the positions of both S and T but I suppose I need to find the position of the repeated T however there more than 1. The worlds coordinates system starts at 0,0 at the top left and 0 degrees for the direction could start at West. It seems like this shouldn’t be too hard but I haven’t been able to work out a solution. I hope somone can help? Any websites would be appreciated.

    Read the article

  • Can't get sprite to rotate correctly?

    - by rphello101
    I'm attempting to play with graphics using Java/Slick 2d. I'm trying to get my sprite to rotate to wherever the mouse is on the screen and then move accordingly. I figured the best way to do this was to keep track of the angle the sprite is at since I have to multiply the cosine/sine of the angle by the move speed in order to get the sprite to go "forwards" even if it is, say, facing 45 degrees in quadrant 3. However, before I even worry about that, I'm having trouble even getting my sprite to rotate in the first place. Preliminary console tests showed that this code worked, but when applied to the sprite, it just kind twitches. Anyone know what's wrong? int mX = Mouse.getX(); int mY = HEIGHT - Mouse.getY(); int pX = sprite.x; int pY = sprite.y; int tempY, tempX; double mAng, pAng = sprite.angle; double angRotate=0; if(mX!=pX){ tempY=pY-mY; tempX=mX-pX; mAng = Math.toDegrees(Math.atan2(Math.abs((tempY)),Math.abs((tempX)))); if(mAng==0 && mX<=pX) mAng=180; } else{ if(mY>pY) mAng=270; else mAng=90; } //Calculations if(mX<pX&&mY<pY){ //If in Q2 mAng = 180-mAng; } if(mX<pX&&mY>pY){ //If in Q3 mAng = 180+mAng; } if(mX>pX&&mY>pY){ //If in Q4 mAng = 360-mAng; } angRotate = mAng-pAng; sprite.angle = mAng; sprite.image.setRotation((float)angRotate);

    Read the article

  • XNA C# Rectangle Intersect Ball on a Square

    - by user2436057
    I made a Game like Peggle Deluxe using C# and XNA for lerning. I have 2 rectangles a ball and a square field. The ball gets shoot out with a cannon and if the Ball hits the Square the Square disapears and the Ball flys away.But the Ball doesent spring of realistically, it sometimes flys away in a different direction or gets stuck on the edge. Thads my Code at the moment: public void Update(Ball b, Deadline dl) { ArrayList listToDelete = new ArrayList(); foreach (Field aField in allFields) { if (aField.square.Intersects(b.ballhere)) { listToDelete.Add(aField); Punkte = Punkte + 100; float distanceX = Math.Abs(b.ballhere.X - aField.square.X); float distanceY = Math.Abs(b.ballhere.Y - aField.square.Y); if (distanceX < distanceY) { b.myMovement.X = -b.myMovement.X; } else { b.myMovement.Y = -b.myMovement.Y; } } } It changes the X or Y axis depending on how the ball hits the Square but not everytimes. What could cause the problem? Thanks for your answer. Greetings from Switzerland.

    Read the article

  • Platform game collisions with Block

    - by Sri Harsha Chilakapati
    I am trying to create a platform game and doing wrong collision detection with the blocks. Here's my code // Variables GTimer jump = new GTimer(1000); boolean onground = true; // The update method public void update(long elapsedTime){ MapView.follow(this); // Add the gravity if (!onground && !jump.active){ setVelocityY(4); } // Jumping if (isPressed(VK_SPACE) && onground){ jump.start(); setVelocityY(-4); onground = false; } if (jump.action(elapsedTime)){ // jump expired jump.stop(); } // Horizontal movement setVelocityX(0); if (isPressed(VK_LEFT)){ setVelocityX(-4); } if (isPressed(VK_RIGHT)){ setVelocityX(4); } } // The collision method public void collision(GObject other){ if (other instanceof Block){ // Determine the horizontal distance between centers float h_dist = Math.abs((other.getX() + other.getWidth()/2) - (getX() + getWidth()/2)); // Now the vertical distance float v_dist = Math.abs((other.getY() + other.getHeight()/2) - (getY() + getHeight()/2)); // If h_dist > v_dist horizontal collision else vertical collision if (h_dist > v_dist){ // Are we moving right? if (getX()<other.getX()){ setX(other.getX()-getWidth()); } // Are we moving left? else if (getX()>other.getX()){ setX(other.getX()+other.getWidth()); } } else { // Are we moving up? if (jump.active){ jump.stop(); } // We are moving down else { setY(other.getY()-getHeight()); setVelocityY(0); onground = true; } } } } The problem is that the object jumps well but does not fall when moved out of platform. Here's an image describing the problem. I know I'm not checking underneath the object but I don't know how. The map is a list of objects and should I have to iterate over all the objects??? Thanks

    Read the article

  • Reduce weight in healthy way

    - by krnites
    This post is my daily summary of activities that I am going to take to reduce my overall weight by 15 lbs. I am not an overweight person as per my height of 5.11 I have decent weight of 178.4 and good body build. But from a long time(approx 3 month) I am thinking of getting 2-3 abs (note not 6 abs) and reducing my weight to below 170 ( which I was 2 years ago). This post will work as my daily diary of what I ate, what exercises I did, what apps/software I used to monitor my weight loss. Sometime it will not contain much information but some time when I will research will contain information for people who really want to reduce weight. My current target for next few week is to run 2.5 miles everyday under 30 minutes. Eat a lot of fruits and vegetable. No burger or tacos. No meat either fat or lean. And checking body weight after every four hour. Here are reading for today10:00 AM  - 178.22:00 PM    - 178.4I have already ran for 2 miles in 25 minutes, did a little bit of shoulder exercise and had eaten small bowl of vegetable biryani and two bread.I hope this post and all coming post will give the reader the first hand experience of a person who had read every blog and articles related to reducing weight and now trying to do it by implementing all of them by self. My approach will be a healthy way of reducing weight, I am not going to starve my self or going to eat only fruits all day. I will enjoy all the food item that I like to eat and will work hard on my body. This way I will / reduce the weight naturally and will increase the flexibility, durability and immunity of my system /body.

    Read the article

  • Java Slick2d - Mouse picking how to take into account camera

    - by Corey
    When I move it it obviously changes the viewport so my mouse picking is off. My camera is just a float x and y and I use g.translate(-cam.cameraX+400, -cam.cameraY+300); to translate the graphics. I have the numbers hard coded just for testing purposes. How would I take into account the camera so my mouse picking works correctly. double mousetileX = Math.floor((double)mouseX/tiles.tileWidth); double mousetileY = Math.floor((double)mouseY/tiles.tileHeight); double playertileX = Math.floor(playerX/tiles.tileWidth); double playertileY = Math.floor(playerY/tiles.tileHeight); double lengthX = Math.abs((float)playertileX - mousetileX); double lengthY = Math.abs((float)playertileY - mousetileY); double distance = Math.sqrt((lengthX*lengthX)+(lengthY*lengthY)); if(input.isMousePressed(Input.MOUSE_LEFT_BUTTON) && distance < 4) { if(tiles.map[(int)mousetileX][(int)mousetileY] == 1) { tiles.map[(int)mousetileX][(int)mousetileY] = 0; } } That is my mouse picking code

    Read the article

  • Collision Detection Problems

    - by MrPlosion
    So I'm making a 2D tile based game but I can't quite get the collisions working properly. I've taken the code from the Platformer Sample and implemented it into my game as seen below. One problem I'm having is when I'm on the ground for some strange reason I can't move to the left. Now I'm pretty sure this problem is from the HandleCollisions() method because when I stop running it I can smoothly move around with no problems. Another problem I'm having is when I'm close to a tile the character jitters very strangely. I will try to post a video if necessary. Here is the HandleCollisions() method: Thanks. void HandleCollisions() { Rectangle bounds = BoundingRectangle; int topTile = (int)Math.Floor((float)bounds.Top / World.PixelTileSize); int bottomTile = (int)Math.Ceiling((float)bounds.Bottom / World.PixelTileSize) - 1; int leftTile = (int)Math.Floor((float)bounds.Left / World.PixelTileSize); int rightTile = (int)Math.Ceiling((float)bounds.Right / World.PixelTileSize) - 1; isOnGround = false; for(int x = leftTile; x <= rightTile; x++) { for(int y = topTile; y <= bottomTile; y++) { if(world.Map[y, x].Collidable == true) { Rectangle tileBounds = new Rectangle(x * World.PixelTileSize, y * World.PixelTileSize, World.PixelTileSize, World.PixelTileSize); Vector2 depth = RectangleExtensions.GetIntersectionDepth(bounds, tileBounds); if(depth != Vector2.Zero) { if(Math.Abs(depth.Y) < Math.Abs(depth.X)) { isOnGround = true; position = new Vector2(position.X, position.Y + depth.Y); } else { position = new Vector2(position.X + depth.X, position.Y); } bounds = BoundingRectangle; } } } }

    Read the article

  • How to define a function in ghci across multiple lines

    - by Peter McGrattan
    I'm trying to define any simple function that spans multiple lines in ghci, take the following as an example: let abs n | n >= 0 = n | otherwise = -n So far I've tried pressing Enter after the first line: Prelude> let abs n | n >= 0 = n Prelude> | otherwise = -n <interactive>:1:0: parse error on input `|' I've also attempted to use the :{ and :} commands but I don't get far: Prelude> :{ unknown command ':{' use :? for help. I'm using GHC Interactive version 6.6 for Haskell 98 on Linux, what am I missing?

    Read the article

  • Smooth animation using MatrixTransform?

    - by Mattias Konradsson
    I'm trying to do an Matrix animation where I both scale and transpose a canvas at the same time. The only approach I found was using a MatrixTransform and MatrixAnimationUsingKeyFrames. Since there doesnt seem to be any interpolation for matrices built in (only for path/rotate) it seems the only choice is to try and build the interpolation and DiscreteMatrixKeyFrame's yourself. I did a basic implementation of this but it isnt exactly smooth and I'm not sure if this is the best way and how to handle framerates etc. Anyone have suggestions for improvement? Here's the code: MatrixAnimationUsingKeyFrames anim = new MatrixAnimationUsingKeyFrames(); int duration = 1; anim.KeyFrames = Interpolate(new Point(0, 0), centerPoint, 1, factor,100,duration); this.matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, anim,HandoffBehavior.Compose); public MatrixKeyFrameCollection Interpolate(Point startPoint, Point endPoint, double startScale, double endScale, double framerate,double duration) { MatrixKeyFrameCollection keyframes = new MatrixKeyFrameCollection(); double steps = duration * framerate; double milliSeconds = 1000 / framerate; double timeCounter = 0; double diffX = Math.Abs(startPoint.X- endPoint.X); double xStep = diffX / steps; double diffY = Math.Abs(startPoint.Y - endPoint.Y); double yStep = diffY / steps; double diffScale= Math.Abs(startScale- endScale); double scaleStep = diffScale / steps; if (endPoint.Y < startPoint.Y) { yStep = -yStep; } if (endPoint.X < startPoint.X) { xStep = -xStep; } if (endScale < startScale) { scaleStep = -scaleStep; } Point currentPoint = new Point(); double currentScale = startScale; for (int i = 0; i < steps; i++) { keyframes.Add(new DiscreteMatrixKeyFrame(new Matrix(currentScale, 0, 0, currentScale, currentPoint.X, currentPoint.Y), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(timeCounter)))); currentPoint.X += xStep; currentPoint.Y += yStep; currentScale += scaleStep; timeCounter += milliSeconds; } keyframes.Add(new DiscreteMatrixKeyFrame(new Matrix(endScale, 0, 0, endScale, endPoint.X, endPoint.Y), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); return keyframes; }

    Read the article

  • Web service creates stack overflow

    - by mouthpiec
    I have an application that when executed as a windows application works fine, but when converted to a web service, in some instances (which were tested successfully) by the windows app) creates a stack overflow. Do you have an idea of what can cause this? (Note that it works fine when the web service is placed on the localhost). Could it be that the stack size of a Web Service is smaller than that of a Window Application? UPDATE The below is the code in which I am getting a stack overflow error private bool CheckifPixelsNeighbour(Pixel c1, Pixel c2, int DistanceAllowed) { bool Neighbour = false; if ((Math.Abs(c1.X - c2.X) <= DistanceAllowed) && Math.Abs(c1.Y - c2.Y) <= DistanceAllowed) { Neighbour = true; } return Neighbour; }

    Read the article

  • Using Cepstrum for PDA

    - by CziX
    Hey, I am currently deleveloping a algorithm to decide wheather or not a frame is voiced or unvoiced. I am trying to use the Cepstrum to discriminate between these two situations. I use MATLAB for my implementation. I have some problems, saying something generally about the frame, but my currently implementation looks like (I'm award of the MATLAB has the function rceps, but this haven't worked for either): ceps = abs(ifft(log10(abs(fft(frame.*window')).^2+eps))); Can anybody give me a small demo, that will convert the frame to the power cepstrum, so a single lollipop at the pitch frequency. For instance use this code to generate the frequency. fs = 8000; timelength = 25e-3; freq = 500; k = 0:1/fs:timelength-(1/fs); s = 0.8*sin(2*pi*freq*k); Thanks.

    Read the article

  • average velocity, as3

    - by VideoDnd
    Hello, I need something accurate I can plug equations in to if you can help. How would you apply the equation bellow? Thanks guys. AVERAGE VELOCITY AND DISPLACEMENT average velocity V=X/T displacement x=v*T more info example I have 30 seconds and a field that is 170 yards. What average velocity would I need my horse to travel at to reach the end of the field in 30 seconds. I moved the decimal places around and got this. Here's what I tried 'the return value is close, but not close enough' FLA here var TIMER:int = 10; var T:int = 0; var V:int = 5.6; var X:int = 0; var Xf:int = 17000/10*2; var timer:Timer = new Timer(TIMER,Xf); timer.addEventListener(TimerEvent.TIMER, incrementCounter); timer.start(); function formatCount(i:int):String { var fraction:int = Math.abs(i % 100); var whole:int = Math.abs(i / 100); return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction); } function incrementCounter(event:TimerEvent) { T++; X = Math.abs(V*T); text.text = formatCount(X); } tests TARGET 5.6yards * 30seconds = 168yards INTEGERS 135.00 in 30 seconds MATH.ROUND 135.00 in 30 seconds NUMBERS 140.00 in 30 seconds control timer 'I tested with this and the clock on my desk' var timetest:Timer = new Timer(1000,30); var Dplus:int = 17000; timetest.addEventListener(TimerEvent.TIMER, cow); timetest.start(); function cow(evt:TimerEvent):void { tx.text = String("30 SECONDS: " + timetest.currentCount); if(timetest.currentCount> Dplus){ timetest.stop(); } } //far as I got...couldn't get delta to work... T = (V*timer.currentCount); X += Math.round(T);

    Read the article

  • Webservice creates Stack Overflow

    - by mouthpiec
    I have an application that when executed as a windows application works fine, but when converted to a webservice, in some instances (which were tested successfully) by the windows app) creates a stack overflow. Do you have an idea of what can cause this? (Note that it works fine when the web service is placed on the localhost). Could it be that the stack size of a Web Service is smaller than that of a Window Application? UPDATE The below is the code in which I am getting a stack overflow error private bool CheckifPixelsNeighbour(Pixel c1, Pixel c2, int DistanceAllowed) { bool Neighbour = false; if ((Math.Abs(c1.X - c2.X) <= DistanceAllowed) && Math.Abs(c1.Y - c2.Y) <= DistanceAllowed) { Neighbour = true; } return Neighbour; }

    Read the article

  • Android draw using SurfaceView and Thread

    - by Morten Høgseth
    I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving and shifts direction when hitting the wall like the picture below (this is using the code in the link). Now I like to separate the classes into 3 different pages for not making everything so crowded, everything is set up the same way. Here are the 3 classes I have. BallActivity.java Ball.java BallThread.java package com.brick.breaker; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class BallActivity extends Activity { private Ball ball; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); ball = new Ball(this); setContentView(ball); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); setContentView(null); ball = null; finish(); } } package com.brick.breaker; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.view.SurfaceHolder; import android.view.SurfaceView; public class Ball extends SurfaceView implements SurfaceHolder.Callback { private BallThread ballThread = null; private Bitmap bitmap; private float x, y; private float vx, vy; public Ball(Context context) { super(context); // TODO Auto-generated constructor stub bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ball); x = 50.0f; y = 50.0f; vx = 10.0f; vy = 10.0f; getHolder().addCallback(this); ballThread = new BallThread(getHolder(), this); } protected void onDraw(Canvas canvas) { update(canvas); canvas.drawBitmap(bitmap, x, y, null); } public void update(Canvas canvas) { checkCollisions(canvas); x += vx; y += vy; } public void checkCollisions(Canvas canvas) { if(x - vx < 0) { vx = Math.abs(vx); } else if(x + vx > canvas.getWidth() - getBitmapWidth()) { vx = -Math.abs(vx); } if(y - vy < 0) { vy = Math.abs(vy); } else if(y + vy > canvas.getHeight() - getBitmapHeight()) { vy = -Math.abs(vy); } } public int getBitmapWidth() { if(bitmap != null) { return bitmap.getWidth(); } else { return 0; } } public int getBitmapHeight() { if(bitmap != null) { return bitmap.getHeight(); } else { return 0; } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // TODO Auto-generated method stub } public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub ballThread.setRunnable(true); ballThread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { // TODO Auto-generated method stub boolean retry = true; ballThread.setRunnable(false); while(retry) { try { ballThread.join(); retry = false; } catch(InterruptedException ie) { //Try again and again and again } break; } ballThread = null; } } package com.brick.breaker; import android.graphics.Canvas; import android.view.SurfaceHolder; public class BallThread extends Thread { private SurfaceHolder sh; private Ball ball; private Canvas canvas; private boolean run = false; public BallThread(SurfaceHolder _holder,Ball _ball) { sh = _holder; ball = _ball; } public void setRunnable(boolean _run) { run = _run; } public void run() { while(run) { canvas = null; try { canvas = sh.lockCanvas(null); synchronized(sh) { ball.onDraw(canvas); } } finally { if(canvas != null) { sh.unlockCanvasAndPost(canvas); } } } } public Canvas getCanvas() { if(canvas != null) { return canvas; } else { return null; } } } Here is a picture that shows the outcome of these classes. I've tried to figure this out but since I am pretty new to Android development I thought I could ask for help. Does any one know what is causing the ball to be draw like that? The code is pretty much the same as the one in the link and I have tried to experiment to find a solution but no luck. Thx in advance for any help=)

    Read the article

  • Regular Expression find a phrase not inside an HTML tag

    - by James Buckingham
    Hi there, I'm struggling a bit with this regular expression and wondered if anyone was about to help me please? What I need to do is isolate the 1st phrase inside a string which is NOT inside an HTML tag. So the examples I have at the moment are: This is some test text about ITS for the ITS department. Also worth mentioning ABS as well I guess.ITS, ... and ... This is some ITS test text about ITS for the ITS department. Also worth mentioning ABS as well I guess So in the first example I want it to ignore the wrapped ITS and give me the ITS at the end of the 1st sentence. In the second example I want it to return the ITS at the start of the 2nd sentence. The aim is to replace these with my own custom wrapped acronym tags in a ColdFusion application I'm writing. Thanks a lot, James

    Read the article

  • Java M4A atom tagging free space issue

    - by Brett
    Hey, I've been trying to be able to read and write iTunes style M4A atoms and while I've successfully done the reading part, I've come to a bit of a halt in regards to the free space atoms. I figured that I should be able edit and shift the padding around to accommodate writing an atom with more data than it originally had. I've been stuck on this for about a day now, and I've been trying to figure out how to determine the closest free space atom with enough size to accommodate the new data. so far I have: private freeAtom acquireFreeSpaceAtom( long position ) { long atomStart = Long.MAX_VALUE; freeAtom atom = null; for( freeAtom a : freeSpace ) { if( Math.abs( position - atomStart ) > Math.abs( position - a.getAtomStart() ) ) atomStart = ( atom = a ).getAtomStart(); } return atom; } That code only takes into account the closest free space atom and completely disregards the fact that it should be greater than or equal to a certain size, but I can't quite figure out how I should check for both closeness and size efficiently.

    Read the article

  • How to move a kinect skeleton to another position

    - by Ewerton
    I am working on a extension method to move one skeleton to a desired position in the kinect field os view. My code receives a skeleton to be moved and the destiny position, i calculate the distance between the received skeleton hip center and the destiny position to find how much to move, then a iterate in the joint applying this factor. My code, actualy looks like this. public static Skeleton MoveTo(this Skeleton skToBeMoved, Vector4 destiny) { Joint newJoint = new Joint(); ///Based on the HipCenter (i dont know if it is reliable, seems it is.) float howMuchMoveToX = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.X - destiny.X); float howMuchMoveToY = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.Y - destiny.Y); float howMuchMoveToZ = Math.Abs(skToBeMoved.Joints[JointType.HipCenter].Position.Z - destiny.Z); float howMuchToMultiply = 1; // Iterate in the 20 Joints foreach (JointType item in Enum.GetValues(typeof(JointType))) { newJoint = skToBeMoved.Joints[item]; // This adjust, try to keeps the skToBeMoved in the desired position if (newJoint.Position.X < 0) howMuchToMultiply = 1; // if the point is in a negative position, carry it to a "more positive" position else howMuchToMultiply = -1; // if the point is in a positive position, carry it to a "more negative" position // applying the new values to the joint SkeletonPoint pos = new SkeletonPoint() { X = newJoint.Position.X + (howMuchMoveToX * howMuchToMultiply), Y = newJoint.Position.Y, // * (float)whatToMultiplyY, Z = newJoint.Position.Z, // * (float)whatToMultiplyZ }; newJoint.Position = pos; skToBeMoved.Joints[item] = newJoint; //if (skToBeMoved.Joints[JointType.HipCenter].Position.X < 0) //{ // if (item == JointType.HandLeft) // { // if (skToBeMoved.Joints[item].Position.X > 0) // { // } // } //} } return skToBeMoved; } Actualy, only X position is considered. Now, THE PROBLEM: If i stand in a negative position, and move my hand to a positive position, a have a strange behavior, look this image To reproduce this behaviour you could use this code using (SkeletonFrame frame = e.OpenSkeletonFrame()) { if (frame == null) return new Skeleton(); if (skeletons == null || skeletons.Length != frame.SkeletonArrayLength) { skeletons = new Skeleton[frame.SkeletonArrayLength]; } frame.CopySkeletonDataTo(skeletons); Skeleton skeletonToTest = skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault(); Vector4 newPosition = new Vector4(); newPosition.X = -0.03412333f; newPosition.Y = 0.0407479f; newPosition.Z = 1.927342f; newPosition.W = 0; // ignored skeletonToTest.MoveTo(newPosition); } I know, this is simple math, but i cant figure it out why this is happen. Any help will be apreciated.

    Read the article

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