Search Results

Search found 647 results on 26 pages for 'aj sin dhal'.

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

  • Rebuild whole page on callback?

    - by AJ
    Hello, In asp.net is it a requirement to rebuild the whole page during every callback? For example my web page is split into three distinct areas and I have an update panel for each area. Lets say I want to update the third area, do I have to bother with any processing of the other two areas? For example lets say there is a grid view in area two. The update panel in area three callbacks to update its content. Do I have to rebind the grid in area two? Thanks, AJ

    Read the article

  • List.AddRange inline declaration

    - by AJ
    Hello, This may seem an easy question, but not to me, also a search has led to nothing. Up until now the only .net programming I have done is with Delphi Prism. With Prism I can do things like: var l := new List<String>(['A','B','C']); or var l := new List<String>; l.AddRange(['A','B','C']; but can I do a similar thing in C#, or do I have to do it like: var a = new String[] {"A","B","C"}; var l = new List<String>(a); Thanks, AJ

    Read the article

  • Why does just splitting an Ethernet cable not work?

    - by Sin Jeong-hun
    I thought the Ethernet is logically a one-line communication bus (for argument's sake, I am excluding hubs). All machines attached on the bus hears the same signals and the machines themselves try to avoid collisions by randomly backing off. http://computer.howstuffworks.com/ethernet6.htm If so, why would splitting one Ethernet line from my home router into two and connecting two computers not work? Why do I have to add a switch to it? *What the Internet said would not work. [4 port home router] ------[one Ethernet cable]-----[simple splitter]======[two computers] *What the Internet said I should do [4 port home router] ------[one Ethernet cable]-----[switch]======[two computers] Is this because of the signal degradation (reduced electric current)? Thank you for all the answers! The reason why I did not just use the two ports of my home router is... The 4-port gigabit router is in my room, and I had put a computer in another room (also my room, though). Since a wired network is far more reliable and secure, I had bought a long Ethernet cable and and connected the computer to the router. Now I was thinking about adding another computer to that room. I could buy another long Ethernet cable, but then there will be two cables between the rooms. The one line already is a minor annoyance, so I thought if I could share the one line between the two computers in that room. A switch would work, but it requires power and is a little bit pricey. That is why I wondered why it would not work to simply split the physical Ethernet cable. Apparently I do not completely understand how Ethernet and a switch work. I just have some bit of knowledge I heard in my college class.

    Read the article

  • After making boot disk using rufus in usb 3.0 port, it doesn't work in another ports.

    - by sin
    I have a big problem! After making boot disk using rufus in usb 3.0 port, it doesn't work in another ports. I have to install windows in other PC which has usb 2.0port only! so I made usb booting disk using usb 3.0 in 3.0 port. but after that it never worked except in 3.0 ... and I could't restore my usb. I alredy fomated in cmd and others in usb3.0 port! but there is no change. and I couldn't find it in usb 2.0 port. plz help me.

    Read the article

  • Why just splitting an Ethernet cable does not work?

    - by Sin Jeong-hun
    I thought the Ethernet is logically one-line communication bus (for argument's sake, I am excluding hubs). All machines attached in the bus hears the same signals and the machines themselves try to avoid collisions by randomly backing off. http://computer.howstuffworks.com/ethernet6.htm If so, why splitting one Ethernet line from my home router into two and connecting two computers would not work? Why do I have to add a switch to it? *What the Internet said would not work. [4 port home router] ------[one Ethernet cable]-----[simple splitter]======[two computers] *What the Internet said I should do [4 port home router] ------[one Ethernet cable]-----[switch]======[two computers] Is this because of the signal degradation (reduced electric current)? Thank you for all the answers! The reason why I did not just use the two ports of my home router is... The 4-port gigabit router is in my room and I had put a computer in another room (also my room, though). Since wired network is far more reliable and secure, I had bought a long Ethernet cable and and connected the computer to the router. Now I was thinking about adding another computer to that room. I could buy another long Ethernet cable, but then there will be two cables between the rooms. The one line already is a minor annoyance, so I thought if I could share the one line between the two computers in that room. A switch would work, but it requires power and is a little bit pricey. That is why I wondered why it would not work to simply split the physical Ethernet cable. Apparently I do not completely understand how Ethernet and a switch work. I just have some bit of knowledge I heard in my college class.

    Read the article

  • What is dmake actually doing when installing a new module?

    - by aj-sin-dhal
    I just mangaged to install the perl/Tk module after much struggle. I realise I don't understand what dmake or make etc is actually doing. I am using strawberry perl installed at C:\strawberry. Fisrt I unpacked the module to another directory and ran perl makefile.pl which worked fine. Then I tried dmake which did not work. I guess that will be obvious to people who know how this works. When I placed the module as a sub-directory of C:\strawberry I could run perl makefile.pl, dmake, dmake test and dmake install. My guess is that dmake install is adding some executable files to the interpreter and to work the module must be in a subdirectory. Is there any article anywhere that explains what it is doing in detail?

    Read the article

  • Fixing a collision detection bug in Slick2D

    - by Jesse Prescott
    My game has a bug with collision detection. If you go against the wall and tap forward/back sometimes the game thinks the speed you travelled at is 0 and the game doesn't know how to get you out of the wall. My collision detection works by getting the speed you hit the wall at and if it is positive it moves you back, if it is negative it moves you forward. It might help if you download it: https://rapidshare.com/files/1550046269/game.zip Sorry if I explained badly, it's hard to explain. float maxSpeed = 0.3f; float minSpeed = -0.2f; float acceleration = 0.002f; float deacceleration = 0.001f; float slowdownSpeed = 0.002f; float rotateSpeed = 0.08f; static float currentSpeed = 0; boolean up = false; boolean down = false; boolean noKey = false; static float rotate = 0; //Image effect system static String locationCarNormal; static String locationCarFront; static String locationCarBack; static String locationCarBoth; static boolean carFront = false; static boolean carBack = false; static String imageRef; boolean collision = false; public ComponentPlayerMovement(String id, String ScarNormal, String ScarFront, String ScarBack, String ScarBoth) { this.id = id; playerBody = new Rectangle(900/2-16, 700/2-16, 32, 32); locationCarNormal = ScarNormal; locationCarFront = ScarFront; locationCarBack = ScarBack; locationCarBoth = ScarBoth; imageRef = locationCarNormal; } @Override public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); playerBody.transform(Transform.createRotateTransform(2)); float hip = currentSpeed * delta; float unstuckspeed = 0.05f * delta; if(carBack && !carFront) { imageRef = locationCarBack; ComponentImageRender.updateImage(); } else if(carFront && !carBack) { imageRef = locationCarFront; ComponentImageRender.updateImage(); } else if(carFront && carBack) { imageRef = locationCarBoth; ComponentImageRender.updateImage(); } if(input.isKeyDown(Input.KEY_RIGHT)) { rotate += rotateSpeed * delta; owner.setRotation(rotate); } if(input.isKeyDown(Input.KEY_LEFT)) { rotate -= rotateSpeed * delta; owner.setRotation(rotate); } if(input.isKeyDown(Input.KEY_UP)) { if(!collision) { up = true; noKey = false; if(currentSpeed < maxSpeed) { currentSpeed += acceleration; } MapCoordStorage.mapX += hip * Math.sin(Math.toRadians(rotate)); MapCoordStorage.mapY -= hip * Math.cos(Math.toRadians(rotate)); } else { currentSpeed = 1; } } else if(input.isKeyDown(Input.KEY_DOWN) && !collision) { down = true; noKey = false; if(currentSpeed > minSpeed) { currentSpeed -= slowdownSpeed; } MapCoordStorage.mapX += hip * Math.sin(Math.toRadians(rotate)); MapCoordStorage.mapY -= hip * Math.cos(Math.toRadians(rotate)); } else { noKey = true; if(currentSpeed > 0) { currentSpeed -= deacceleration; } else if(currentSpeed < 0) { currentSpeed += acceleration; } MapCoordStorage.mapX += hip * Math.sin(Math.toRadians(rotate)); MapCoordStorage.mapY -= hip * Math.cos(Math.toRadians(rotate)); } if(entityCollisionWith()) { collision = true; if(currentSpeed > 0 || up) { up = true; currentSpeed = 0; carFront = true; MapCoordStorage.mapX += unstuckspeed * Math.sin(Math.toRadians(rotate-180)); MapCoordStorage.mapY -= unstuckspeed * Math.cos(Math.toRadians(rotate-180)); } else if(currentSpeed < 0 || down) { down = true; currentSpeed = 0; carBack = true; MapCoordStorage.mapX += unstuckspeed * Math.sin(Math.toRadians(rotate)); MapCoordStorage.mapY -= unstuckspeed * Math.cos(Math.toRadians(rotate)); } else { currentSpeed = 0; } } else { collision = false; up = false; down = false; } if(currentSpeed >= -0.01f && currentSpeed <= 0.01f && noKey && !collision) { currentSpeed = 0; } } public static boolean entityCollisionWith() throws SlickException { for (int i = 0; i < BlockMap.entities.size(); i++) { Block entity1 = (Block) BlockMap.entities.get(i); if (playerBody.intersects(entity1.poly)) { return true; } } return false; } }

    Read the article

  • Segmentation fault in my C program

    - by user233542
    I don't understand why this would give me a seg fault. Any ideas? This is the function that returns the signal to stop the program (plus the other function that is called within this): double bisect(double A0,double A1,double Sol[N],double tol,double c) { double Amid,shot; while (A1-A0 > tol) { Amid = 0.5*(A0+A1); shot = shoot(Sol, Amid, c); if (shot==2.*Pi) { return Amid; } if (shot > 2.*Pi){ A1 = Amid; } else if (shot < 2.*Pi){ A0 = Amid; } } return 0.5*(A1+A0); } double shoot(double Sol[N],double A,double c) { int i,j; /*Initial Conditions*/ for (i=0;i<buff;i++) { Sol[i] = 0.; } for (i=buff+l;i<N;i++) { Sol[i] = 2.*Pi; } Sol[buff]= 0; Sol[buff+1]= A*exp(sqrt(1+3*c)*dx); for (i=buff+2;i<buff+l;i++) { Sol[i] = (dx*dx)*( sin(Sol[i-1]) + c*sin(3.*(Sol[i-1])) ) - Sol[i-2] + 2.*Sol[i-1]; } return Sol[i-1]; } The values buff, l, N are defined using a #define statement. l = 401, buff = 50, N = 2000 Here is the full code: #include <stdio.h> #include <stdlib.h> #include <math.h> #define w 10 /*characteristic width of a soliton*/ #define dx 0.05 /*distance between lattice sites*/ #define s (2*w)/dx /*size of soliton shape*/ #define l (int)(s+1) /*array length for soliton*/ #define N (int)2000 /*length of field array--lattice sites*/ #define Pi (double)4*atan(1) #define buff (int)50 double shoot(double Sol[N],double A,double c); double bisect(double A0,double A1,double Sol[N],double tol,double c); void super_pos(double antiSol[N],double Sol[N],double phi[][N]); void vel_ver(double phi[][N],double v,double c,int tsteps,double dt); int main(int argc, char **argv) { double c,Sol[N],antiSol[N],A,A0,A1,tol,v,dt; int tsteps,i; FILE *fp1,*fp2,*fp3; fp1 = fopen("soliton.dat","w"); fp2 = fopen("final-phi.dat","w"); fp3 = fopen("energy.dat","w"); printf("Please input the number of time steps:"); scanf("%d",&tsteps); printf("Also, enter the time step size:"); scanf("%lf",&dt); do{ printf("Please input the parameter c in the interval [-1/3,1]:"); scanf("%lf",&c);} while(c < (-1./3.) || c > 1.); printf("Please input the inital speed of eiter soliton:"); scanf("%lf",&v); double phi[tsteps+1][N]; tol = 0.0000001; A0 = 0.; A1 = 2.*Pi; A = bisect(A0,A1,Sol,tol,c); shoot(Sol,A,c); for (i=0;i<N;i++) { fprintf(fp1,"%d\t",i); fprintf(fp1,"%lf\n",Sol[i]); } fclose(fp1); super_pos(antiSol,Sol,phi); /*vel_ver(phi,v,c,tsteps,dt); for (i=0;i<N;i++){ fprintf(fp2,"%d\t",i); fprintf(fp2,"%lf\n",phi[tsteps][i]); }*/ } double shoot(double Sol[N],double A,double c) { int i,j; /*Initial Conditions*/ for (i=0;i<buff;i++) { Sol[i] = 0.; } for (i=buff+l;i<N;i++) { Sol[i] = 2.*Pi; } Sol[buff]= 0; Sol[buff+1]= A*exp(sqrt(1+3*c)*dx); for (i=buff+2;i<buff+l;i++) { Sol[i] = (dx*dx)*( sin(Sol[i-1]) + c*sin(3.*(Sol[i-1])) ) - Sol[i-2] + 2.*Sol[i-1]; } return Sol[i-1]; } double bisect(double A0,double A1,double Sol[N],double tol,double c) { double Amid,shot; while (A1-A0 > tol) { Amid = 0.5*(A0+A1); shot = shoot(Sol, Amid, c); if (shot==2.*Pi) { return Amid; } if (shot > 2.*Pi){ A1 = Amid; } else if (shot < 2.*Pi){ A0 = Amid; } } return 0.5*(A1+A0); } void super_pos(double antiSol[N],double Sol[N],double phi[][N]) { int i; /*for (i=0;i<N;i++) { phi[i]=0; } for (i=buffer+s;i<1950-s;i++) { phi[i]=2*Pi; }*/ for (i=0;i<N;i++) { antiSol[i] = Sol[N-i]; } /*for (i=0;i<s+1;i++) { phi[buffer+j] = Sol[j]; phi[1549+j] = antiSol[j]; }*/ for (i=0;i<N;i++) { phi[0][i] = antiSol[i] + Sol[i] - 2.*Pi; } } /* This funciton will set the 2nd input array to the derivative at the time t, for all points x in the lattice */ void deriv2(double phi[][N],double DphiDx2[][N],int t) { //double SolDer2[s+1]; int x; for (x=0;x<N;x++) { DphiDx2[t][x] = (phi[buff+x+1][t] + phi[buff+x-1][t] - 2.*phi[x][t])/(dx*dx); } /*for (i=0;i<N;i++) { ptr[i] = &SolDer2[i]; }*/ //return DphiDx2[x]; } void vel_ver(double phi[][N],double v,double c,int tsteps,double dt) { int t,x; double d1,d2,dp,DphiDx1[tsteps+1][N],DphiDx2[tsteps+1][N],dpdt[tsteps+1][N],p[tsteps+1][N]; for (t=0;t<tsteps;t++){ if (t==0){ for (x=0;x<N;x++){//inital conditions deriv2(phi,DphiDx2,t); dpdt[t][x] = DphiDx2[t][x] - sin(phi[t][x]) - sin(3.*phi[t][x]); DphiDx1[t][x] = (phi[t][x+1] - phi[t][x])/dx; p[t][x] = -v*DphiDx1[t][x]; } } for (x=0;x<N;x++){//velocity-verlet phi[t+1][x] = phi[t][x] + dt*p[t][x] + (dt*dt/2)*dpdt[t][x]; p[t+1][x] = p[t][x] + (dt/2)*dpdt[t][x]; deriv2(phi,DphiDx2,t+1); dpdt[t][x] = DphiDx2[t][x] - sin(phi[t+1][x]) - sin(3.*phi[t+1][x]); p[t+1][x] += (dt/2)*dpdt[t+1][x]; } } } So, this really isn't due to my overwriting the end of the Sol array. I've commented out both functions that I suspected of causing the problem (bisect or shoot) and inserted a print function. Two things happen. When I have code like below: double A,Pi,B,c; c=0; Pi = 4.*atan(1.); A = Pi; B = 1./4.; printf("%lf",B); B = shoot(Sol,A,c); printf("%lf",B); I get a segfault from the function, shoot. However, if I take away the shoot function so that I have: double A,Pi,B,c; c=0; Pi = 4.*atan(1.); A = Pi; B = 1./4.; printf("%lf",B); it gives me a segfault at the printf... Why!?

    Read the article

  • Point inside Oriented Bounding Box?

    - by Milo
    I have an OBB2D class based on SAT. This is my point in OBB method: public boolean pointInside(float x, float y) { float newy = (float) (Math.sin(angle) * (y - center.y) + Math.cos(angle) * (x - center.x)); float newx = (float) (Math.cos(angle) * (x - center.x) - Math.sin(angle) * (y - center.y)); return (newy > center.y - (getHeight() / 2)) && (newy < center.y + (getHeight() / 2)) && (newx > center.x - (getWidth() / 2)) && (newx < center.x + (getWidth() / 2)); } public boolean pointInside(Vector2D v) { return pointInside(v.x,v.y); } Here is the rest of the class; the parts that pertain: public class OBB2D { private Vector2D projVec = new Vector2D(); private static Vector2D projAVec = new Vector2D(); private static Vector2D projBVec = new Vector2D(); private static Vector2D tempNormal = new Vector2D(); private Vector2D deltaVec = new Vector2D(); private ArrayList<Vector2D> collisionPoints = new ArrayList<Vector2D>(); // Corners of the box, where 0 is the lower left. private Vector2D corner[] = new Vector2D[4]; private Vector2D center = new Vector2D(); private Vector2D extents = new Vector2D(); private RectF boundingRect = new RectF(); private float angle; //Two edges of the box extended away from corner[0]. private Vector2D axis[] = new Vector2D[2]; private double origin[] = new double[2]; public OBB2D(float centerx, float centery, float w, float h, float angle) { for(int i = 0; i < corner.length; ++i) { corner[i] = new Vector2D(); } for(int i = 0; i < axis.length; ++i) { axis[i] = new Vector2D(); } set(centerx,centery,w,h,angle); } public OBB2D(float left, float top, float width, float height) { for(int i = 0; i < corner.length; ++i) { corner[i] = new Vector2D(); } for(int i = 0; i < axis.length; ++i) { axis[i] = new Vector2D(); } set(left + (width / 2), top + (height / 2),width,height,0.0f); } public void set(float centerx,float centery,float w, float h,float angle) { float vxx = (float)Math.cos(angle); float vxy = (float)Math.sin(angle); float vyx = (float)-Math.sin(angle); float vyy = (float)Math.cos(angle); vxx *= w / 2; vxy *= (w / 2); vyx *= (h / 2); vyy *= (h / 2); corner[0].x = centerx - vxx - vyx; corner[0].y = centery - vxy - vyy; corner[1].x = centerx + vxx - vyx; corner[1].y = centery + vxy - vyy; corner[2].x = centerx + vxx + vyx; corner[2].y = centery + vxy + vyy; corner[3].x = centerx - vxx + vyx; corner[3].y = centery - vxy + vyy; this.center.x = centerx; this.center.y = centery; this.angle = angle; computeAxes(); extents.x = w / 2; extents.y = h / 2; computeBoundingRect(); } //Updates the axes after the corners move. Assumes the //corners actually form a rectangle. private void computeAxes() { axis[0].x = corner[1].x - corner[0].x; axis[0].y = corner[1].y - corner[0].y; axis[1].x = corner[3].x - corner[0].x; axis[1].y = corner[3].y - corner[0].y; // Make the length of each axis 1/edge length so we know any // dot product must be less than 1 to fall within the edge. for (int a = 0; a < axis.length; ++a) { float l = axis[a].length(); float ll = l * l; axis[a].x = axis[a].x / ll; axis[a].y = axis[a].y / ll; origin[a] = corner[0].dot(axis[a]); } } public void computeBoundingRect() { boundingRect.left = JMath.min(JMath.min(corner[0].x, corner[3].x), JMath.min(corner[1].x, corner[2].x)); boundingRect.top = JMath.min(JMath.min(corner[0].y, corner[1].y),JMath.min(corner[2].y, corner[3].y)); boundingRect.right = JMath.max(JMath.max(corner[1].x, corner[2].x), JMath.max(corner[0].x, corner[3].x)); boundingRect.bottom = JMath.max(JMath.max(corner[2].y, corner[3].y),JMath.max(corner[0].y, corner[1].y)); } public void set(RectF rect) { set(rect.centerX(),rect.centerY(),rect.width(),rect.height(),0.0f); } // Returns true if other overlaps one dimension of this. private boolean overlaps1Way(OBB2D other) { for (int a = 0; a < axis.length; ++a) { double t = other.corner[0].dot(axis[a]); // Find the extent of box 2 on axis a double tMin = t; double tMax = t; for (int c = 1; c < corner.length; ++c) { t = other.corner[c].dot(axis[a]); if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } } // We have to subtract off the origin // See if [tMin, tMax] intersects [0, 1] if ((tMin > 1 + origin[a]) || (tMax < origin[a])) { // There was no intersection along this dimension; // the boxes cannot possibly overlap. return false; } } // There was no dimension along which there is no intersection. // Therefore the boxes overlap. return true; } public void moveTo(float centerx, float centery) { float cx,cy; cx = center.x; cy = center.y; deltaVec.x = centerx - cx; deltaVec.y = centery - cy; for (int c = 0; c < 4; ++c) { corner[c].x += deltaVec.x; corner[c].y += deltaVec.y; } boundingRect.left += deltaVec.x; boundingRect.top += deltaVec.y; boundingRect.right += deltaVec.x; boundingRect.bottom += deltaVec.y; this.center.x = centerx; this.center.y = centery; computeAxes(); } // Returns true if the intersection of the boxes is non-empty. public boolean overlaps(OBB2D other) { if(right() < other.left()) { return false; } if(bottom() < other.top()) { return false; } if(left() > other.right()) { return false; } if(top() > other.bottom()) { return false; } if(other.getAngle() == 0.0f && getAngle() == 0.0f) { return true; } return overlaps1Way(other) && other.overlaps1Way(this); } public Vector2D getCenter() { return center; } public float getWidth() { return extents.x * 2; } public float getHeight() { return extents.y * 2; } public void setAngle(float angle) { set(center.x,center.y,getWidth(),getHeight(),angle); } public float getAngle() { return angle; } public void setSize(float w,float h) { set(center.x,center.y,w,h,angle); } public float left() { return boundingRect.left; } public float right() { return boundingRect.right; } public float bottom() { return boundingRect.bottom; } public float top() { return boundingRect.top; } public RectF getBoundingRect() { return boundingRect; } public boolean overlaps(float left, float top, float right, float bottom) { if(right() < left) { return false; } if(bottom() < top) { return false; } if(left() > right) { return false; } if(top() > bottom) { return false; } return true; } public static float distance(float ax, float ay,float bx, float by) { if (ax < bx) return bx - ay; else return ax - by; } public Vector2D project(float ax, float ay) { projVec.x = Float.MAX_VALUE; projVec.y = Float.MIN_VALUE; for (int i = 0; i < corner.length; ++i) { float dot = Vector2D.dot(corner[i].x,corner[i].y,ax,ay); projVec.x = JMath.min(dot, projVec.x); projVec.y = JMath.max(dot, projVec.y); } return projVec; } public Vector2D getCorner(int c) { return corner[c]; } public int getNumCorners() { return corner.length; } public boolean pointInside(float x, float y) { float newy = (float) (Math.sin(angle) * (y - center.y) + Math.cos(angle) * (x - center.x)); float newx = (float) (Math.cos(angle) * (x - center.x) - Math.sin(angle) * (y - center.y)); return (newy > center.y - (getHeight() / 2)) && (newy < center.y + (getHeight() / 2)) && (newx > center.x - (getWidth() / 2)) && (newx < center.x + (getWidth() / 2)); } public boolean pointInside(Vector2D v) { return pointInside(v.x,v.y); } public ArrayList<Vector2D> getCollsionPoints(OBB2D b) { collisionPoints.clear(); for(int i = 0; i < corner.length; ++i) { if(b.pointInside(corner[i])) { collisionPoints.add(corner[i]); } } for(int i = 0; i < b.corner.length; ++i) { if(pointInside(b.corner[i])) { collisionPoints.add(b.corner[i]); } } return collisionPoints; } }; What could be wrong? When I getCollisionPoints for 2 OBBs I know are penetrating, it returns no points. Thanks

    Read the article

  • Morph a sphere to a cube and a cube to a sphere with GLSL

    - by nkint
    I'm getting started with GLSL with quartz composer. I have a patch with a particle system in which each particle is mapped into a sphere with a blend value. With blend=0 particles are in random positions, blend=1 particles are in the sphere. The code is here: vec3 sphere(vec2 domain) { vec3 range; range.x = radius * cos(domain.y) * sin(domain.x); range.y = radius * sin(domain.y) * sin(domain.x); range.z = radius * cos(domain.x); return range; } // in main: vec2 p0 = gl_Vertex.xy * twopi; vec3 normal = sphere(p0);; vec3 r0 = radius * normal; vec3 vertex = r0; normal = normal * blend + gl_Normal * (1.0 - blend); vertex = vertex * blend + gl_Vertex.xyz * (1.0 - blend); I'd like the particle to be on a cube if blend=0 I've tried to find but I can't figure out some parametric equation for the cube. Maybe it is not the right way?

    Read the article

  • OpenGL texture on sphere

    - by Cilenco
    I want to create a rolling, textured ball in OpenGL ES 1.0 for Android. With this function I can create a sphere: public Ball(GL10 gl, float radius) { ByteBuffer bb = ByteBuffer.allocateDirect(40000); bb.order(ByteOrder.nativeOrder()); sphereVertex = bb.asFloatBuffer(); points = build(); } private int build() { double dTheta = STEP * Math.PI / 180; double dPhi = dTheta; int points = 0; for(double phi = -(Math.PI/2); phi <= Math.PI/2; phi+=dPhi) { for(double theta = 0.0; theta <= (Math.PI * 2); theta+=dTheta) { sphereVertex.put((float) (raduis * Math.sin(phi) * Math.cos(theta))); sphereVertex.put((float) (raduis * Math.sin(phi) * Math.sin(theta))); sphereVertex.put((float) (raduis * Math.cos(phi))); points++; } } sphereVertex.position(0); return points; } public void draw() { texture.bind(); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sphereVertex); gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, points); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); } My problem now is that I want to use this texture for the sphere but then only a black ball is created (of course because the top right corner s black). I use this texture coordinates because I want to use the whole texture: 0|0 0|1 1|1 1|0 That's what I learned from texturing a triangle. Is that incorrect if I want to use it with a sphere? What do I have to do to use the texture correctly?

    Read the article

  • what does AngleVectors method in quake 3 source code does

    - by kypronite
    I just downloaded quake 3 for learning purposes. I know some of some linear algebra(basic vector math ie: dot,cross product). However I can't decipher what below method does, I know what is yaw,pitch and roll. But I can't connect these with vector. Worse, I'm not sure this fall under what math 'category', so I don't really know how to google. Hence the question here. Anyone? void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) { float angle; static float sr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs angle = angles[YAW] * (M_PI*2 / 360); sy = sin(angle); cy = cos(angle); angle = angles[PITCH] * (M_PI*2 / 360); sp = sin(angle); cp = cos(angle); angle = angles[ROLL] * (M_PI*2 / 360); sr = sin(angle); cr = cos(angle); if (forward) { forward[0] = cp*cy; forward[1] = cp*sy; forward[2] = -sp; } if (right) { right[0] = (-1*sr*sp*cy+-1*cr*-sy); right[1] = (-1*sr*sp*sy+-1*cr*cy); right[2] = -1*sr*cp; } if (up) { up[0] = (cr*sp*cy+-sr*-sy); up[1] = (cr*sp*sy+-sr*cy); up[2] = cr*cp; } } ddddd

    Read the article

  • Oscillating Sprite Movement in XNA

    - by Nick Van Hoogenstyn
    I'm working on a 2d game and am looking to make a sprite move horizontally across the screen in XNA while oscillating vertically (basically I want the movement to look like a sin wave). Currently for movement I'm using two vectors, one for speed and one for direction. My update function for sprites just contains this: Position += direction * speed * (float)t.ElapsedGameTime.TotalSeconds; How could I utilize this setup to create the desired movement? I'm assuming I'd call Math.Sin or Math.Cos, but I'm unsure of where to start to make this sort of thing happened. My attempt looked like this: public override void Update(GameTime t) { double msElapsed = t.TotalGameTime.Milliseconds; mDirection.Y = (float)Math.Sin(msElapsed); if (mDirection.Y >= 0) mSpeed.Y = moveSpeed; else mSpeed.Y = -moveSpeed; base.Update(t, mSpeed, mDirection); } moveSpeed is just some constant positive integer. With this, the sprite simply just continuously moves downward until it's off screen. Can anyone give me some info on what I'm doing wrong here? I've never tried something like this so if I'm doing things completely wrong, let me know!

    Read the article

  • Arbitrary Rotation about a Sphere

    - by Der
    I'm coding a mechanic which allows a user to move around the surface of a sphere. The position on the sphere is currently stored as theta and phi, where theta is the angle between the z-axis and the xz projection of the current position (i.e. rotation about the y axis), and phi is the angle from the y-axis to the position. I explained that poorly, but it is essentially theta = yaw, phi = pitch Vector3 position = new Vector3(0,0,1); position.X = (float)Math.Sin(phi) * (float)Math.Sin(theta); position.Y = (float)Math.Sin(phi) * (float)Math.Cos(theta); position.Z = (float)Math.Cos(phi); position *= r; I believe this is accurate, however I could be wrong. I need to be able to move in an arbitrary pseudo two dimensional direction around the surface of a sphere at the origin of world space with radius r. For example, holding W should move around the sphere in an upwards direction relative to the orientation of the player. I believe I should be using a Quaternion to represent the position/orientation on the sphere, but I can't think of the correct way of doing it. Spherical geometry is not my strong suit. Essentially, I need to fill the following block: public void Move(Direction dir) { switch (dir) { case Direction.Left: // update quaternion to rotate left break; case Direction.Right: // update quaternion to rotate right break; case Direction.Up: // update quaternion to rotate upward break; case Direction.Down: // update quaternion to rotate downward break; } }

    Read the article

  • Electronic circuit simulator four-way flood-filling issues

    - by AJ Weeks
    I've made an electronic circuit board simulator which has simply 3 types of tiles: wires, power sources, and inverters. Wires connect to anything they touch, other than the sides of inverters; inverters have one input side and one output side; and finally power tiles connect in a similar manner as wires. In the case of an infinite loop, caused by the output of the inverter feeding into its input, I want inverters to oscillate (quickly turn on/off). I've attempted to implement a FloodFill algorithm to spread the power throughout the grid, but seem to have gotten something wrong, as only the tiles above the power source get powered (as seen below) I've attempted to debug the program, but have had no luck thus far. My code concerning the updating of power can be seen here.

    Read the article

  • Help needed on a UI/Developer Interview

    - by AJ Seth
    I have a phone interview with a major Internet company and it is a mostly front-end developer position. If anyone has experience with UI/developer interviews and can give some advice/questions asked etc. that'll be great. Additionally, what resources can be read and reviewed for the following: Designing for performance, scalability and availability Internet and OS security fundamentals EDIT: Now I am told that the interview I am told will be mostly on coding, Data Structures, design questions etc. Anyone?

    Read the article

  • Ubuntu 12.04 connected to wireless network but internet not working

    - by A.J.
    I can connect to my house's wireless network just fine, but when I'm connected I can't browse the web. Firefox starts connecting to a site and then just poops out. This doesn't happen on my roommates' computers (running Windows) or on our 3DSes, so I know it's just my laptop. I already tried sudo dhclient -r sudo dhclient sudo ifconfig eth0 down sudo ifconfig eth0 up Results of a few commands I was asked to run in comments: ping -c 2 4.2.2.2 PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data. ^C --- 4.2.2.2 ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 1007ms ping -c 2 google.com PING google.com (173.194.33.38) 56(84) bytes of data. --- google.com ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 1006ms nm-tool NetworkManager Tool State: connected (global) - Device: eth0 ----------------------------------------------------------------- Type: Wired Driver: atl1c State: unavailable Default: no HW Address: 88:AE:1D:6B:4E:E7 Capabilities: Carrier Detect: yes Speed: 100 Mb/s Wired Properties Carrier: off - Device: wlan0 [JUSTICE] ----------------------------------------------------- Type: 802.11 WiFi Driver: ath9k State: connected Default: yes HW Address: 1C:65:9D:65:C6:31 Capabilities: Speed: 1 Mb/s Wireless Properties WEP Encryption: yes WPA Encryption: yes WPA2 Encryption: yes Wireless Access Points (* = current AP) HOME-9B18: Infra, 00:26:F3:53:9B:18, Freq 2412 MHz, Rate 54 Mb/s, Strength 34 WPA WPA2 cougdad48 Network: Infra, 60:33:4B:E4:C4:5D, Freq 2437 MHz, Rate 54 Mb/s, Strength 22 WPA2 cougdad48 Guest Network: Infra, 66:33:4B:E4:C4:5D, Freq 2437 MHz, Rate 54 Mb/s, Strength 20 WPA2 belkin.ade: Infra, 94:44:52:FF:8A:DE, Freq 2457 MHz, Rate 54 Mb/s, Strength 20 WPA WPA2 *JUSTICE: Infra, 00:24:01:7B:9F:7E, Freq 2462 MHz, Rate 54 Mb/s, Strength 88 WEP CenturyLink: Infra, B2:B2:DC:8E:E2:58, Freq 2462 MHz, Rate 54 Mb/s, Strength 17 WPA WPA2 IPv4 Settings: Address: 192.168.0.11 Prefix: 24 (255.255.255.0) Gateway: 192.168.0.1 DNS: 192.168.0.1 (JUSTICE is my home's network.) ping -c 2 198.168.0.1 PING 198.168.0.1 (198.168.0.1) 56(84) bytes of data. --- 198.168.0.1 ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 1007ms

    Read the article

  • Installing drivers for an ATI 6950

    - by aj.esler
    Is there any way to get ubuntu to recognise an ATI 6950? I have tried installing the proprietary ATI drivers, but these do not seem to work properly. It seems to screw up the gnome desktop, and starts booting into terminal. I'm somewhat of a linux newbie, so not really sure whats going wrong. I don't want to game on ubuntu, I just want it to recognise my dual monitor setup rather than mirroring the monitors, so any driver that does this is fine by me. It seems like the open source ATI radeon drivers will not support the 6950/6970 for some time, at least until kernel 2.6.38 is released. The card is also flashed with the 6970 firmware, not sure if this is important. I am running a 64 bit version of ubuntu, I installed ubuntu server 10.10, then installed gnome-desktop.

    Read the article

  • Installing drivers for an ATI 6950 in Ubuntu

    - by aj.esler
    Is there any way to get ubuntu to recognise an ATI 6950? I have tried installing the proprietary ATI drivers, but these do not seem to work properly. It seems to screw up the gnome desktop, and starts booting into terminal. I'm somewhat of a linux newbie, so not really sure whats going wrong. I don't want to game on ubuntu, I just want it to recognise my dual monitor setup rather than mirroring the monitors, so any driver that does this is fine by me. It seems like the open source ATI radeon drivers will not support the 6950/6970 for some time, at least until kernel 2.6.38 is released. The card is also flashed with the 6970 firmware, not sure if this is important. I am running a 64 bit version of ubuntu, I installed ubuntu server 10.10, then installed gnome-desktop.

    Read the article

  • How to do a multishot in xna?

    - by DeVonte
    I am trying to simulate a gun in which shoots multiple bullets at the same time(similar to a spread out shot). I am thinking I have to create another bullet array then do the same as I have below but in a different direction. Here is what I have so far: foreach (GameObject bullet in bullets) { // Find a bullet that isn't alive if (!bullet.alive) { //And set it to alive bullet.alive = true; if (flip == SpriteEffects.FlipHorizontally) //Facing right { float armCos = (float)Math.Cos(arm.rotation - MathHelper.PiOver2); float armSin = (float)Math.Sin(arm.rotation - MathHelper.PiOver2); // Set the initial position of our bullets at the end of our gun arm // 42 is obtained by taking the width of the Arm_Gun texture / 2 // and subtracting the width of the Bullet texture / 2. ((96/2)=(12/2)) bullet.position = new Vector2( arm.position.X + 42 * armCos, arm.position.Y + 42 * armSin); // And give it a velocity of the direction we're aiming. // Increae/decrease speed by changeing 15.0f bullet.Velocity = new Vector2( (float)Math.Cos(arm.rotation - MathHelper.PiOver4 + MathHelper.Pi + MathHelper.PiOver2), (float)Math.Sin(arm.rotation - MathHelper.PiOver4 + MathHelper.Pi + MathHelper.PiOver2)) * 15.0f; } else //Facing left { float armCos = (float)Math.Cos(arm.rotation + MathHelper.PiOver2); float armSin = (float)Math.Sin(arm.rotation + MathHelper.PiOver2); //Set the initial position of our bullet at the end of our gun arm //42 is obtained be taking the width of the Arm_Gun texture / 2 //and subtracting the width of the Bullet texture / 2. ((96/2)-(12/2)) bullet.position = new Vector2( arm.position.X - 42 * armCos, arm.position.Y - 42 * armSin); //And give it a velocity of the direction we're aiming. //Increase/decrease speed by changing 15.0f bullet.Velocity = new Vector2( -armCos, -armSin) * 15.0f; } return; }// End if }// End foreach

    Read the article

  • historical weather data APIs

    - by AJ.
    I am building a web application where I need to display whole year's month wise weather conditions. So that users get an idea of what the weather conditions are like and plan their trips accordingly. I am using WunderGround's History feature but it does not give this data for smaller towns and destinations, even some very popular tourist destinations. Are there any alternatives which could provide me the same information.

    Read the article

  • Subsonic : Can’t decide which property to consider the Key? foreign key issue.

    - by AJ
    Hi I am trying to select count of rows from a table which has foreign keys of two tables. The C# code threw the error mentioned below. So, I added a primary key column to the table (schema as follows) and regenerated the code. But still the same error is coming. Error : Can't decide which property to consider the Key - you can create one called 'ID' or mark one with SubSonicPrimaryKey attribute sqLite Table schema CREATE TABLE "AlbumDocuments" ("Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "AlbumId" INTEGER NOT NULL CONSTRAINT fk_AlbumId REFERENCES Albums(Id) , "DocumentId" INTEGER NOT NULL CONSTRAINT fk_DocumentId REFERENCES Documents(Id)) C# code int selectAlbumDocumentsCount = new SubSonic.Query.Select() .From<DocSafeDB.DataLayer.AlbumDocumentsTable>() .Where(DocSafeDB.DataLayer.AlbumDocumentsTable.AlbumIdColumn).In(request.AlbumId) .Execute(); Not sure what I should be doing next as I can't do where against primary key because I don;t have that info. So my questions are: How do I select count of rows against foreign key column? Is primary key required in this scenario? I have several things but not sure why its not working. To me it looks like a very normal use case. Please advise. Thanks AJ

    Read the article

  • Typecasting EnityObject

    - by AJ
    Hello, I'm new to C# and am stuck on the following. I have a Silverlight web service that uses LINQ to query a ADO.NET entity object. e.g.: [OperationContract] public List<Customer> GetData() { using (TestEntities ctx = new TestEntities()) { var data = from rec in ctx.Customer select rec; return data.ToList(); } } This works fine, but what I want to do is to make this more abstract. The first step would be to return a List<EntityObject> but this gives a compiler error, e.g.: [OperationContract] public List<EntityObject> GetData() { using (TestEntities ctx = new TestEntities()) { var data = from rec in ctx.Customer select rec; return data.ToList(); } } The error is: Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<SilverlightTest.Web.Customer>' to 'System.Collections.Generic.IEnumerable<System.Data.Objects.DataClasses.EntityObject>'. An explicit conversion exists (are you missing a cast?) What am i doing wrong? Thanks, AJ

    Read the article

  • Generic list typecasting problem

    - by AJ
    Hello, I'm new to C# and am stuck on the following. I have a Silverlight web service that uses LINQ to query a ADO.NET entity object. e.g.: [OperationContract] public List<Customer> GetData() { using (TestEntities ctx = new TestEntities()) { var data = from rec in ctx.Customer select rec; return data.ToList(); } } This works fine, but what I want to do is to make this more abstract. The first step would be to return a List<EntityObject> but this gives a compiler error, e.g.: [OperationContract] public List<EntityObject> GetData() { using (TestEntities ctx = new TestEntities()) { var data = from rec in ctx.Customer select rec; return data.ToList(); } } The error is: Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<SilverlightTest.Web.Customer>' to 'System.Collections.Generic.IEnumerable<System.Data.Objects.DataClasses.EntityObject>'. An explicit conversion exists (are you missing a cast?) What am i doing wrong? Thanks, AJ

    Read the article

  • Dependent Dropdowns (Linked Selects) with single class (no other selectors)

    - by AJ
    I am trying to create multiple dependent dropdowns (selects) with a unique way. I want to restrict the use of selectors and want to achieve this by using a single class selectors on all SELECTs; by figuring out the SELECT that was changed by its index. Hence, the SELECT[i] that changed will change the SELECT[i+1] only (and not the previous ones like SELECT[i-1]). For html like this: <select class="someclass"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> <select class="someclass"> </select> <select class="someclass"> </select> where the SELECTs other than the first one will get something via AJAX. I see that the following Javascript gives me correct value of the correct SELECT and the value of i also corresponds to the correct SELECT. $(function() { $(".someclass").each(function(i) { $(this).change(function(x) { alert($(this).val() + i); }); }); }); Please note that I really want the minimum selector approach. I just cannot wrap my head around on how to approach this. Should I use Arrays? Like store all the SELECTS in an Array first and then select those? I believe that since the above code already passes the index i, there should be a way without Arrays also. Thanks a bunch. AJ

    Read the article

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