Search Results

Search found 614 results on 25 pages for 'vectors'.

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

  • Vectors with Circles Physics -java

    - by Joe Hearty
    This is a problem I've been having, When making a set number of filled circles at random locations on a JPanel and applying a gravity (a negative change in the y), each of the circles collide. I want them to have collision detection and push in the opposite direction using vectors but i don't know how to apply that to my scenario could someone help? public void drawballs(Graphics g){ g.setColor (Color.white); //displays circles for(int i = 0; i<xlocationofcircles.length-1; i++){ g.fillOval( (int) xlocationofcircles[i], (int) (ylocationofcircles[i]) ,16 ,16 ); ylocationofcircles[i]+=.2; //gravity if(ylocationofcircles[i] > 550) //stops gravity at bottom of screen ylocationofcircles[i]-=.2; //Check distance between circles(i think..) float distance =(xlocationofcircles[i+1]-xlocationofcircles[i]) + (ylocationofcircles[i+1]-xlocationofcircles[i]) ; if( Math.sqrt(distance) <16)

    Read the article

  • I am looking to create realistic car movement using vectors

    - by bobthemac
    I have goggled how to do this and found this http://www.helixsoft.nl/articles/circle/sincos.htm I have had a go at it but most of the functions that were showed didn't work I just got errors because they didn't exist. I have looked at the cos and sin functions but don't understand how to use them or how to get the car movement working correctly using vectors. I have no code because I am not sure what to do sorry. Any help is appreciated. EDIT: I have restrictions that I must use the TL engine for my game, I am not allowed to add any sort of physics engine. It must be programmed in c++. Here is a sample of what i got from trying to follow what was done in the link I provided. if(myEngine->KeyHeld(Key_W)) { length += carSpeedIncrement; } if(myEngine->KeyHeld(Key_S)) { length -= carSpeedIncrement; } if(myEngine->KeyHeld(Key_A)) { angle -= carSpeedIncrement; } if(myEngine->KeyHeld(Key_D)) { angle += carSpeedIncrement; } carVolocityX = cos(angle); carVolocityZ = cos(angle); car->MoveX(carVolocityX * frameTime); car->MoveZ(carVolocityZ * frameTime);

    Read the article

  • Drawing a texture line between two vectors in XNA WP7

    - by Krav
    I want to create a simple graph maker in WP7. The goal is to draw a texture line between two vectors what the user defines with touch. I already made the rotation, and it is working, but not correctly, because it doesn't calculate the line's texture height, and because of that, there are too many overlapping textures. So it does draw the line, but too many of them. How could I calculate it correctly? Here is the code: public void DrawLine(Vector2 st,Vector2 dest,NodeUnit EdgeParent,NodeUnit EdgeChild) { float d = Vector2.Distance(st, dest); float rotate = (float)(Math.Atan2(st.Y - dest.Y, st.X - dest.X)); direction = new Vector2(((dest.X - st.X) / (float)d), (dest.Y - st.Y) / (float)d); Vector2 _pos = st; World.TheHive.Add(new LineHiveMind(linetexture, _pos, rotate, EdgeParent, EdgeChild,new List<LineUnit>())); for (int i = 0; i < d; i++) { World.TheHive.Last()._lines.Add(new LineUnit(linetexture, _pos, rotate, EdgeParent, EdgeChild)); _pos += direction; } } d is for the Distance of the st (Starting node) and dest (Destination node) rotate is for rotation direction calculates the direction between the starting and the destination node _pos is for starting position changing Thanks for any suggestions/help!

    Read the article

  • GLM Velocity Vectors - Basic Maths to Simulate Steering

    - by Reanimation
    UPDATE - Code updated below but still need help adjusting my math. I have a cube rendered on the screen which represents a car (or similar). Using Projection/Model matrices and Glm I am able to move it back and fourth along the axes and rotate it left or right. I'm having trouble with the vector mathematics to make the cube move forwards no matter which direction it's current orientation is. (ie. if I would like, if it's rotated right 30degrees, when it's move forwards, it travels along the 30degree angle on a new axes). I hope I've explained that correctly. This is what I've managed to do so far in terms of using glm to move the cube: glm::vec3 vel; //velocity vector void renderMovingCube(){ glUseProgram(movingCubeShader.handle()); GLuint matrixLoc4MovingCube = glGetUniformLocation(movingCubeShader.handle(), "ProjectionMatrix"); glUniformMatrix4fv(matrixLoc4MovingCube, 1, GL_FALSE, &ProjectionMatrix[0][0]); glm::mat4 viewMatrixMovingCube; viewMatrixMovingCube = glm::lookAt(camOrigin, camLookingAt, camNormalXYZ); vel.x = cos(rotX); vel.y=sin(rotX); vel*=moveCube; //move cube ModelViewMatrix = glm::translate(viewMatrixMovingCube,globalPos*vel); //bring ground and cube to bottom of screen ModelViewMatrix = glm::translate(ModelViewMatrix, glm::vec3(0,-48,0)); ModelViewMatrix = glm::rotate(ModelViewMatrix, rotX, glm::vec3(0,1,0)); //manually turn glUniformMatrix4fv(glGetUniformLocation(movingCubeShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &ModelViewMatrix[0][0]); //pass matrix to shader movingCube.render(); //draw glUseProgram(0); } keyboard input: void keyboard() { char BACKWARD = keys['S']; char FORWARD = keys['W']; char ROT_LEFT = keys['A']; char ROT_RIGHT = keys['D']; if (FORWARD) //W - move forwards { globalPos += vel; //globalPos.z -= moveCube; BACKWARD = false; } if (BACKWARD)//S - move backwards { globalPos.z += moveCube; FORWARD = false; } if (ROT_LEFT)//A - turn left { rotX +=0.01f; ROT_LEFT = false; } if (ROT_RIGHT)//D - turn right { rotX -=0.01f; ROT_RIGHT = false; } Where am I going wrong with my vectors? I would like change the direction of the cube (which it does) but then move forwards in that direction.

    Read the article

  • String vectors not working as expected with newline and iterators? (C++)

    - by kevin
    I have a text file made of 3 lines: Line 1 Line 3 (Line 1, a blank line, and Line 3) vector<string> text; vector<string>::iterator it; ifstream file("test.txt"); string str; while (getline(file, str)) { if (str.length() == 0) str = "\n"; // since getline discards the newline character, replacing blank strings with newline text.push_back(str); } // while for (it=text.begin(); it < text.end(); it++) cout << (*it); Prints out: Line 1 Line 3 I'm not sure why the string with only a newline was not printed out. Any help would be appreciated. Thanks.

    Read the article

  • Any reliable polygon normal calculation code?

    - by Jenko
    I'm currently calculating the normal vector of a polygon using this code, but for some faces here and there it calculates a wrong normal. I don't really know what's going on or where it fails but its not reliable. Do you have any polygon normal calculation that's tested and found to be reliable? // calculate normal of a polygon using all points var n:int = points.length; var x:Number = 0; var y:Number = 0; var z:Number = 0 // ensure all points above 0 var minx:Number = 0, miny:Number = 0, minz:Number = 0; for (var p:int = 0, pl:int = points.length; p < pl; p++) { var po:_Point3D = points[p] = points[p].clone(); if (po.x < minx) { minx = po.x; } if (po.y < miny) { miny = po.y; } if (po.z < minz) { minz = po.z; } } for (p = 0; p < pl; p++) { po = points[p]; po.x -= minx; po.y -= miny; po.z -= minz; } var cur:int = 1, prev:int = 0, next:int = 2; for (var i:int = 1; i <= n; i++) { // using Newell method x += points[cur].y * (points[next].z - points[prev].z); y += points[cur].z * (points[next].x - points[prev].x); z += points[cur].x * (points[next].y - points[prev].y); cur = (cur+1) % n; next = (next+1) % n; prev = (prev+1) % n; } // length of the normal var length:Number = Math.sqrt(x * x + y * y + z * z); // turn large values into a unit vector if (length != 0){ x = x / length; y = y / length; z = z / length; }else { throw new Error("Cannot calculate normal since triangle has an area of 0"); }

    Read the article

  • Trouble with speed and vectors

    - by Eegabooga
    I'm working on adding bullets to my game. Right now I can shoot bullets in the direction that I would like from a ship by getting the ship's angle: int speed = 5; int dx = -(cos(degreesToRadians(ship.angle)) * speed); // rate of change in the x direction int dy = -(sin(degreesToRadians(ship.angle)) * speed); // rate of change in the y direction bulletPosition.addX(dx); // addX(dx) is simply bulletPosition.x += dx bulletPosition.addY(dy); The ship is pretty much the exact same thing, except I use the += operator: int dx += -(cos(degreesToRadians(angle)) * 0.15) int dy += -(sin(degreesToRadians(angle)) * 0.15); shipPosition.addX(dx); shipPosition.addY(dy); I would like to be able to add the ship's velocity to the bullet's velocity, but I'm a little confused as to how should get the speed from the ship's vector. I thought that adding the ship's dx to the bullet's dx like int dx = -(cos(degreesToRadians(ship.angle)) * speed * dx) would work because I'm adding the rate of change of the ship to the rate of change of the bullet, but that doesn't work. So here's the final question: How can I get the speed of my ship and apply it to my bullet's speed? Thanks in advance for all help :)

    Read the article

  • Using Python tuples as vectors

    - by Etaoin
    I need to represent immutable vectors in Python ("vectors" as in linear algebra, not as in programming). The tuple seems like an obvious choice. The trouble is when I need to implement things like addition and scalar multiplication. If a and b are vectors, and c is a number, the best I can think of is this: tuple(map(lambda x,y: x + y, a, b)) # add vectors 'a' and 'b' tuple(map(lambda x: x * c, a)) # multiply vector 'a' by scalar 'c' which seems inelegant; there should be a clearer, simpler way to get this done -- not to mention avoiding the call to tuple, since map returns a list. Is there a better option?

    Read the article

  • Why is joining two vectors simply not working?

    - by Jim
    I have two vectors of MyObj structs. MyObj is defined as follows: struct MyObj { float x, y; unsigned int data[8]; unsigned int tmp[1]; MyObj(const MyObj &m) { x = m.x; y = m.y; tmp[0] = 0; for (int i = 0; i < 8; ++i) { data[i] = m.data[i]; } } }; I then have two vectors... vector<MyObj> v1; vector<MyObj> v2; // both get data eventually. v1.insert(v1.end(), v2.begin(), v2.end()); v2 has 3535004 elements in my experiment. v1 is similarly sized. I've also tried building a new vector and just using .push_back to build it from both vectors. Essentially, when I try to merge the two vectors I just get an error from visual studio saying "Debug error! R6010, abort() has been called". Very non-useful... So my question is: what could be causing this error, and how can I solve it? Thank you

    Read the article

  • Mapping Vectors

    - by Dan Snyder
    Is there a good way to map vectors? Here's an example of what I mean: vec0 = [0,0,0,0,0,0,0,0,0,0,0] vec1 = [1,4,2,7,3,2] vec2 = [0,0,0,0,0,0,0,0,0] vec2 = [7,2,7,9,9,6,1,0,4] vec4 = [0,0,0,0,0,0] mainvec = [0,0,0,0,0,0,0,0,0,0,0,1,4,2,7,3,2,0,0,0,0,0,0,0,0,0,7,2,7,9,9,6,1,0,4,0,0,0,0,0,0] Lets say mainvec doesn't exist (I'm just showing it to you so you can see the general data structure in mind. Now say I want mainvec(12) which would be 4. Is there a good way to map the call of these vectors without just stitching them together into a mainvec? I realize I could make a bunch of if statements that test the index of mainvec and I can then offset each call depending on where the call is within one of the vectors, so for instance: mainvec(12) = vec1(1) which I could do by: mainvec(index) if (index >=13) vect1(index-11); I wonder if there's a concise way of doing this without if statements. Any Ideas?

    Read the article

  • Should I Make These Vectors Classes or Structs in C#

    - by dewald
    I am creating a geometry library in C# and I will need the following immutable types: Vector2f (2 floats - 8 bytes) Vector2d (2 doubles - 16 bytes) Vector3f (3 floats - 12 bytes) Vector3d (3 doubles - 24 bytes) Vector4f (4 floats - 16 bytes) Vector4d (4 doubles - 32 bytes) I am trying to determine whether to make them structs or classes. MSDN suggests only using a struct if the size if going to be no greater than 16 bytes. That reference seems to be from 2005. Is 16 bytes still the max suggested size? I am sure that using structs for the float vectors would be more efficient than using a class, but what should I do about the double vectors? Should I make them structs also to be consistent, or should I make them classes?

    Read the article

  • KMeans clustering for more than 5 million vectors

    - by Wajih
    I have hit a real problem. I need to do some Kmeans clustering for 5 million vectors, each containing about 32 cols. I tried out Mahout which requires linux and I am on windows, I am restrained from using a Linux OS and any sort of simulator. Can anyone suggest a KMeans clustering algorithm that is scalable upto 5M vectors and can converge quickly? I have tested a few but they wont scale. Which means they are slow and take forever to complete. Thanks

    Read the article

  • Calculating the Angle Between Two vectors Using Dot Product

    - by P. Avery
    I'm trying to calculate the angle between two vectors so that I can rotate a character in the direction of an object in 3D space. I have two vectors( character & object), loc_look, and modelPos respectively. For simplicity's sake I am only trying to rotate along the up axis...yaw. loc_look = D3DXVECTOR3 (0, 0, 1), modelPos = D3DXVECTOR3 (0, 0, 15); I have written this code which seems to be the correct calculations. My problem arises, seemingly, because the rotation I apply to the character's look vector(loc_look) exceeds the value of the object's position (modelPos). Here is my code: BOOL CEntity::TARGET() { if(graphics.m_model->m_enemy) { D3DXVECTOR3 modelPos = graphics.m_model->position; D3DXVec3Normalize(&modelPos, &modelPos); //D3DXVec3Normalize(&loc_look, &loc_look); float dot = D3DXVec3Dot(&loc_look, &modelPos); float yaw = acos(dot); BOOL neg = (loc_look.x > modelPos.x) ? true : false; switch ( neg ) { case false: Yaw(yaw); return true; case true: Yaw(-yaw); return true; } } else return false; } I rotate the character's orientation matrix with the following code: void CEntity::CalculateOrientationMatrix(D3DXMATRIX *orientationMatrix) { D3DXMatrixRotationAxis(&rotY, &loc_up, loc_yaw); D3DXVec3TransformCoord(&loc_look, &loc_look, &rotY); D3DXVec3TransformCoord(&loc_right, &loc_right, &rotY); D3DXMatrixRotationAxis(&rotX, &loc_right, loc_pitch); D3DXVec3TransformCoord(&loc_look, &loc_look, &rotX); D3DXVec3TransformCoord(&loc_up, &loc_up, &rotX); D3DXMatrixRotationAxis(&rotZ, &loc_look, loc_roll); D3DXVec3TransformCoord(&loc_up, &loc_up, &rotZ); D3DXVec3TransformCoord(&loc_right, &loc_right, &rotZ); *orientationMatrix *= rotX * rotY * rotZ; orientationMatrix->_41 = loc_position.x; orientationMatrix->_42 = loc_position.y; orientationMatrix->_43 = loc_position.z; //D3DXVec3Normalize(&loc_look, &loc_look); SetYawPitchRoll(0,0,0); // Reset Yaw, Pitch, & Roll Amounts } Also to note, the modelPos.x increases by 0.1 each iteration so the character will face the object as it moves along the x-axis... Now, when I run program, in the first iteration everything is fine(I haven't rotated the character yet). On the second iteration, the loc_look.x value is greater than the modelPos.x value(I rotated the character too much using the angle specified with the dot product calculations in the TARGET function). Therefore on the second iteration my code will rotate the character left to adjust for the difference in the vectors' x values... How can I tighten up the measurements so that I do not rotate my character's look vector by too great a value?

    Read the article

  • Which is the fastest idiomatic way to add all vectors (in the math sense) inside a Scala list?

    - by davips
    I have two solutions, but one doesn't compile and the other, I think, could be better: object Foo extends App { val vectors = List(List(1,2,3), List(2,2,3), List(1,2,2)) //just a stupid example //transposing println("vectors = " + vectors.transpose.map (_.sum)) //it prints vectors = List(4, 6, 8) //folding vectors.reduce { case (a, b) => (a zip b) map { case (x, y) => x + y } } //compiler says: missing parameter type for exp. function; arg. types must be fully known }

    Read the article

  • gluLookAt vectors and FPS-style camera

    - by Kevin Pamplona
    I am attempting to implemented an FPS-style camera by updating three vectors: EYE, DIR, UP. These vectors are the same that are used by gluLookAt (since gluLookAt is specified by the position of the camera, the direction it is looking at, and an up vector). I have already implemented the left-right and up-down strafing movements, but I'm having a lot of trouble understanding the math behind making the camera look-around while remaining stationary. In this case, the EYE vector remains the same, while I must update DIR and UP. Below is the code I tried, but it doesn't seem to work properly. Any suggestions? Thanks. void Transform::left(float degrees, vec3& dir, vec3& up) { vec3 axis; axis = glm::normalize(up); mat3 R = rotate(-degrees, axis); dir = R*dir; dir = R*up; }; void Transform::up(float degrees, vec3& dir, vec3& up) { vec3 axis; axis=glm::normalize(glm::cross(dir,up)); mat3 R = rotate(-degrees, axis); dir = R*dir-; up = R*up; };

    Read the article

  • Vector math, finding coördinates on a planar between 2 vectors

    - by Will Kru
    I am trying to generate a 3d tube along a spline. I have the coördinates of the spline (x1,y1,z1 - x2,y2,z2 - etc) which you can see in the illustration in yellow. At those points I need to generate circles, whose vertices are to be connected at a later stadium. The circles need to be perpendicular to the 'corners' of two line segments of the spline to form a correct tube. Note that the segments are kept low for illustration purpose. [apparently I'm not allowed to post images so please view the image at this link] http://img191.imageshack.us/img191/6863/18720019.jpg I am as far as being able to calculate the vertices of each ring at each point of the spline, but they are all on the same planar ie same angled. I need them to be rotated according to their 'legs' (which A & B are to C for instance). I've been thinking this over and thought of the following: two line segments can be seen as 2 vectors (in illustration A & B) the corner (in illustraton C) is where a ring of vertices need to be calculated I need to find the planar on which all of the vertices will reside I then can use this planar (=vector?) to calculate new vectors from the center point, which is C and find their x,y,z using radius * sin and cos However, I'm really confused on the math part of this. I read about the dot product but that returns a scalar which I don't know how to apply in this case. Can someone point me into the right direction? [edit] To give a bit more info on the situation: I need to construct a buffer of floats, which -in groups of 3- describe vertex positions and will be connected by OpenGL ES, given another buffer with indices to form polygons. To give shape to the tube, I first created an array of floats, which -in groups of 3- describe control points in 3d space. Then along with a variable for segment density, I pass these control points to a function that uses these control points to create a CatmullRom spline and returns this in the form of another array of floats which -again in groups of 3- describe vertices of the catmull rom spline. On each of these vertices, I want to create a ring of vertices which also can differ in density (amount of smoothness / vertices per ring). All former vertices (control points and those that describe the catmull rom spline) are discarded. Only the vertices that form the tube rings will be passed to OpenGL, which in turn will connect those to form the final tube. I am as far as being able to create the catmullrom spline, and create rings at the position of its vertices, however, they are all on a planars that are in the same angle, instead of following the splines path. [/edit] Thanks!

    Read the article

  • solving origin of a vectors

    - by Mike
    I have two endpoints (xa,ya) and (xb,yb) of two vectors, respectively a and b, originating from a same point (xo, yo). Also, I know that |a|=|b|+s, where s is a constant. I tried to compute the origin (xo, yo) but seem to fail at some point. How to solve this?

    Read the article

  • Need help with implementing collision detection using the Separating Axis Theorem

    - by Eddie Ringle
    So, after hours of Googling and reading, I've found that the basic process of detecting a collision using SAT is: for each edge of poly A project A and B onto the normal for this edge if intervals do not overlap, return false end for for each edge of poly B project A and B onto the normal for this edge if intervals do not overlap, return false end for However, as many ways as I try to implement this in code, I just cannot get it to detect the collision. My current code is as follows: for (unsigned int i = 0; i < asteroids.size(); i++) { if (asteroids.valid(i)) { asteroids[i]->Update(); // Player-Asteroid collision detection bool collision = true; SDL_Rect asteroidBox = asteroids[i]->boundingBox; // Bullet-Asteroid collision detection for (unsigned int j = 0; j < player.bullets.size(); j++) { if (player.bullets.valid(j)) { Bullet b = player.bullets[j]; collision = true; if (b.x + (b.w / 2.0f) < asteroidBox.x - (asteroidBox.w / 2.0f)) collision = false; if (b.x - (b.w / 2.0f) > asteroidBox.x + (asteroidBox.w / 2.0f)) collision = false; if (b.y - (b.h / 2.0f) > asteroidBox.y + (asteroidBox.h / 2.0f)) collision = false; if (b.y + (b.h / 2.0f) < asteroidBox.y - (asteroidBox.h / 2.0f)) collision = false; if (collision) { bool realCollision = false; float min1, max1, min2, max2; // Create a list of vertices for the bullet CrissCross::Data::LList<Vector2D *> bullVerts; bullVerts.insert(new Vector2D(b.x - b.w / 2.0f, b.y + b.h / 2.0f)); bullVerts.insert(new Vector2D(b.x - b.w / 2.0f, b.y - b.h / 2.0f)); bullVerts.insert(new Vector2D(b.x + b.w / 2.0f, b.y - b.h / 2.0f)); bullVerts.insert(new Vector2D(b.x + b.w / 2.0f, b.y + b.h / 2.0f)); // Create a list of vectors of the edges of the bullet and the asteroid CrissCross::Data::LList<Vector2D *> bullEdges; CrissCross::Data::LList<Vector2D *> asteroidEdges; for (int k = 0; k < 4; k++) { int n = (k == 3) ? 0 : k + 1; bullEdges.insert(new Vector2D(bullVerts[k]->x - bullVerts[n]->x, bullVerts[k]->y - bullVerts[n]->y)); asteroidEdges.insert(new Vector2D(asteroids[i]->vertices[k]->x - asteroids[i]->vertices[n]->x, asteroids[i]->vertices[k]->y - asteroids[i]->vertices[n]->y)); } for (unsigned int k = 0; k < asteroidEdges.size(); k++) { Vector2D *axis = asteroidEdges[k]->getPerpendicular(); min1 = max1 = axis->dotProduct(asteroids[i]->vertices[0]); for (unsigned int l = 1; l < asteroids[i]->vertices.size(); l++) { float test = axis->dotProduct(asteroids[i]->vertices[l]); min1 = (test < min1) ? test : min1; max1 = (test > max1) ? test : max1; } min2 = max2 = axis->dotProduct(bullVerts[0]); for (unsigned int l = 1; l < bullVerts.size(); l++) { float test = axis->dotProduct(bullVerts[l]); min2 = (test < min2) ? test : min2; max2 = (test > max2) ? test : max2; } delete axis; axis = NULL; if ( (min1 - max2) > 0 || (min2 - max1) > 0 ) { realCollision = false; break; } else { realCollision = true; } } if (realCollision == false) { for (unsigned int k = 0; k < bullEdges.size(); k++) { Vector2D *axis = bullEdges[k]->getPerpendicular(); min1 = max1 = axis->dotProduct(asteroids[i]->vertices[0]); for (unsigned int l = 1; l < asteroids[i]->vertices.size(); l++) { float test = axis->dotProduct(asteroids[i]->vertices[l]); min1 = (test < min1) ? test : min1; max1 = (test > max1) ? test : max1; } min2 = max2 = axis->dotProduct(bullVerts[0]); for (unsigned int l = 1; l < bullVerts.size(); l++) { float test = axis->dotProduct(bullVerts[l]); min2 = (test < min2) ? test : min2; max2 = (test > max2) ? test : max2; } delete axis; axis = NULL; if ( (min1 - max2) > 0 || (min2 - max1) > 0 ) { realCollision = false; break; } else { realCollision = true; } } } if (realCollision) { player.bullets.remove(j); int numAsteroids; float newDegree; srand ( j + asteroidBox.x ); if ( asteroids[i]->degree == 90.0f ) { if ( rand() % 2 == 1 ) { numAsteroids = 3; newDegree = 30.0f; } else { numAsteroids = 2; newDegree = 45.0f; } for ( int k = 0; k < numAsteroids; k++) asteroids.insert(new Asteroid(asteroidBox.x + (10 * k), asteroidBox.y + (10 * k), newDegree)); } delete asteroids[i]; asteroids.remove(i); } while (bullVerts.size()) { delete bullVerts[0]; bullVerts.remove(0); } while (bullEdges.size()) { delete bullEdges[0]; bullEdges.remove(0); } while (asteroidEdges.size()) { delete asteroidEdges[0]; asteroidEdges.remove(0); } } } } } } bullEdges is a list of vectors of the edges of a bullet, asteroidEdges is similar, and bullVerts and asteroids[i].vertices are, obviously, lists of vectors of each vertex for the respective bullet or asteroid. Honestly, I'm not looking for code corrections, just a fresh set of eyes.

    Read the article

  • .NET AES returns wrong Test Vectors

    - by ralu
    I need to implement some crypto protocol on C# and want to say that this is my first project in C#. After spending some time to get used on C# I found out that I am unable to get compliant AES vectors. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Cryptography; using System.IO; namespace ConsoleApplication1 { class Program { public static void Main() { try { //test vectors from "ecb_vk.txt" byte[] key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] encTest = { 0x0e, 0xdd, 0x33, 0xd3, 0xc6, 0x21, 0xe5, 0x46, 0x45, 0x5b, 0xd8, 0xba, 0x14, 0x18, 0xbe, 0xc8 }; AesManaged aesAlg = new AesManaged(); aesAlg.BlockSize = 128; aesAlg.Key = key; aesAlg.Mode = CipherMode.ECB; ICryptoTransform encryptor = aesAlg.CreateEncryptor(); MemoryStream msEncrypt = new MemoryStream(); CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write); StreamWriter swEncrypt = new StreamWriter(csEncrypt); swEncrypt.Write(data); swEncrypt.Close(); csEncrypt.Close(); msEncrypt.Close(); aesAlg.Clear(); byte[] encr; encr = msEncrypt.ToArray(); string datastr = BitConverter.ToString(data); string encrstr = BitConverter.ToString(encr); string encTestStr = BitConverter.ToString(encTest); Console.WriteLine("data: {0}", datastr); Console.WriteLine("encr: {0}", encrstr); Console.WriteLine("should: {0}", encTestStr); Console.ReadKey(); } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } } } } Output is wrong: data: 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 encr: A0-3C-C2-22-A4-32-F7-C9-BA-36-AE-73-66-BD-BB-A3 should: 0E-DD-33-D3-C6-21-E5-46-45-5B-D8-BA-14-18-BE-C8 I am sure that there is a correct AES implementation in .NET, so I need some advice from a .NET wizard to help with this.

    Read the article

  • how to generate String difference vectors?

    - by SWKK
    Hi Guys, a bit of a vague question but I am looking for pointers as to how can I generate String diff vectors in C++. The scenario is such that given a paragraph I want to store the various differences(Edit, cut copy paste etc.) it goes through in a draft mode to review Audit history. Any hints in this regard will be really appreciated.

    Read the article

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