Search Results

Search found 3677 results on 148 pages for 'concurrent vector'.

Page 14/148 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Adding cards to a vector for computer card game

    - by Tucker Morgan
    I am writing a Card game that has a deck size of 30 cards, each one of them has to be a unique, or at least a another (new XXXX) statement in a .push_back function, into a vector. Right now my plan is to add them to a vector one at a time with four separate, depending on what deck type you choose, collections of thirty .push_back functions. If the collection of card is not up for customization, other than what one of the four suits you pick, is there a quicker way of doing this, seems kinda tedious, and something that someone would have found a better way of doing.

    Read the article

  • How to convert poor quality bitmap image to vector?

    - by Macha
    I'm designing a website for a group which has lost the original digital image for their logo. The only file they have of it is a jpg which was embedded into a word document. The image has everything possible wrong with it: Anti-aliased onto a white background where it should be transparent Image artefacts Resized downwards poorly. Lines that should be straight and solid aren't. I've currently used the wand tool to get rid of the white background, and stuck it on the website, but it's poor quality makes it stick out like a sore thumb. I need a few different sizes of it to use, so how would I go about creating a vector image based on it?

    Read the article

  • Rotation matrix for a 3D vector

    - by Shashwat
    I have a direction vector on which I have to apply some rotation to align it to positive z-axis. To use Matrix.CreateRotationX(angle) of XNA, I need the angle for which I'd have to compute cos or tan inverse. I think this is a complex task to do. Also, eventually those are also converted to sin(angle) and cos(angle) in the matrix. Is there any inbuilt way to create rotation matrix from a 3D vector? However, I can write the function but still asking if there is one already there.

    Read the article

  • infer half vector length in BRDF

    - by cician
    it's my first question on stack. Is it possible to infer length of the half angle vector for specular lighting from N·L and N·V without the whole view and light vectors? I may be completely off-track, but I have this gut feeling it's possible... Why? I'm working on a skin shader and I'm already doing one texture lookup with N·L+N·E and one texture lookup for specular with N·H+N·V. The latter one can be transformed into N·L+N·E lookup if only I had the half vector length. Doing so could simplify the shader a bit and move some operations into the pre-computed lookup texture. It would make a huge difference since I'm trying to squeeze as much functionality as possible to a single pass mobile version so instruction count matters. Thanks.

    Read the article

  • A "quick" vector editor (SVG) for Linux (for annotating images?)

    - by sdaau
    I often need to take a bitmap (.png) image, and draw some lines or text on top of it, and possibly export a new, thusly "annotated" image. I know I can basically do all this in inkscape - but inkscape is a complex program, and it needs almost a minute to start up properly on my PCs. So I was thinking - is there something like a "mini" vector editor for Linux, which would start up fast, and allow me to: Right-click, open an image in this editor program The program scales the active "document"/"window size" to the size of the image I can zoom in/zoom out (and possibly crop) the image I can add at least lines, boxes and text in different colors? A bonus for me would be to have the overlay graphics saved as SVG format, say with the same filename as the image - as in, "image.png.svg" being saved in the same directory where the original "image.png" is located (thus allowing opening and editing these "annotations" further, either in this editor, or possibly in inkscape). And another bonus would be the export of the annotated image to a bitmap. Anyone know about anything like this?

    Read the article

  • no match for operator= using a std::vector

    - by Max
    I've got a class declared like this: class Level { private: std::vector<mapObject::MapObject> features; (...) }; and in one of its member functions I try to iterate through that vector like this: vector<mapObject::MapObject::iterator it; for(it=features.begin(); it<features.end(); it++) { /* loop code */ } This seems straightforward to me, but g++ gives me this error: src/Level.cpp:402: error: no match for ‘operator=’ in ‘it = ((const yarl::level::Level*)this)-yarl::level::Level::features.std::vector<_Tp, _Alloc::begin [with _Tp = yarl::mapObject::MapObject, _Alloc = std::allocator<yarl::mapObject::MapObject>]()’ /usr/include/c++/4.4/bits/stl_iterator.h:669: note: candidates are: __gnu_cxx::__normal_iterator<yarl::mapObject::MapObject*,std::vector & __gnu_cxx::__normal_iterator<yarl::mapObject::MapObject*,std::vector >::operator=(const __gnu_cxx::__normal_iterator<yarl::mapObject::MapObject*, ``std::vector<yarl::mapObject::MapObject, std::allocator<yarl::mapObject::MapObject> > >&) Anyone know why this is happening?

    Read the article

  • Basic question about std::vector instantiation

    - by recipriversexclusion
    This looks simple but I am confused: The way I create a vector of hundred, say, ints is std::vector<int> *pVect = new std::vector<int>(100); However, looking at std::vector's documentation I see that its constructor is of the form explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() ); So, how does the previous one work? Does new call the constructor with an initialization value obtained from the default constructor? If that is the case, would std::vector<int, my_allocator> *pVect = new std::vector<int>(100, my_allocator); where I pass my own allocator, also work?

    Read the article

  • How can I eliminate an element in a vector if a condition is met

    - by michael
    Hi, I have a vector of Rect: vector<Rect> myRecVec; I would like to remove the ones which are overlapping in the vector: So I have 2 nested loop like this: vector<Rect>::iterator iter1 = myRecVec.begin(); vector<Rect>::iterator iter2 = myRecVec.begin(); while( iter1 != myRecVec.end() ) { Rectangle r1 = *iter1; while( iter2 != myRecVec.end() ) { Rectangle r2 = *iter1; if (r1 != r2) { if (r1.intersects(r2)) { // remove r2 from myRectVec } } } } My question is how can I remove r2 from the myRectVect without screwing up both my iterators? Since I am iterating a vector and modifying the vector at the same time? I have thought about putting r2 in a temp rectVect and then remove them from the rectVect later (after the iteration). But how can I skip the ones in this temp rectVect during iteration?

    Read the article

  • Why can't I access a const vector with iterator?

    - by tsubasa
    My example is as below. I found out the problem is with "const" in function void test's parameter. I don't know why the compiler does not allow. Could anybody tell me? Thanks. vector<int> p; void test(const vector<int> &blah) { vector<int>::iterator it; for (it=blah.begin(); it!=blah.end(); it++) { cout<<*it<<" "; } } int main() { p.push_back(1); p.push_back(2); p.push_back(3); test(p); return 0; }

    Read the article

  • Reusing a vector in C++

    - by Bobby
    I have a vector declared as a global variable that I need to be able to reuse. For example, I am reading multiple files of data, parsing the data to create objects that are then stored in a vector. vector<Object> objVector(100); void main() { while(THERE_ARE_MORE_FILES_TO_READ) { // Pseudocode ReadFile(); ParseFileIntoVector(); ProcessObjectsInVector(); /* Here I want to 'reset' the vector to 100 empty objects again */ } } Can I reset the vector to be "vector objVector(100)" since it was initially allocated on the stack? If I do "objVector.clear()", it removes all 100 objects and I would have a vector with a size of 0. I need it to be a size of 100 at the start of every loop.

    Read the article

  • Deleting a element from a vector of pointers in C++.

    - by Kranar
    I remember hearing that the following code is not C++ compliant and was hoping someone with much more C++ legalese than me would be able to confirm or deny it. std::vector<int*> intList; intList.push_back(new int(2)); intList.push_back(new int(10)); intList.push_back(new int(17)); for(std::vector<int*>::iterator i = intList.begin(); i != intList.end(); ++i) { delete *i; } intList.clear() The rationale was that it is illegal for a vector to contain pointers to invalid memory. Now obviously my example will compile and it will even work on all compilers I know of, but is it standard compliant C++ or am I supposed to do the following, which I was told is in fact the standard compliant approach: while(!intList.empty()) { int* element = intList.back(); intList.pop_back(); delete element; }

    Read the article

  • hash tables and 2d vectors

    - by Sunil
    I want to push a 2d vector into a hash table row by row and later search for a row (vector) in the hash table and want to be able to find it. I want to do something like #include <iostream> #include <set> #include <vector> using namespace std; int main(){ std::set < vector<int> > myset; vector< vector<int> > v; int k = 0; for ( int i = 0; i < 5; i++ ) { v.push_back ( vector<int>() ); for ( int j = 0; j < 5; j++ ) v[i].push_back ( k++ ); } for ( int i = 0; i < 5; i++ ) { std::copy(v[i].begin(),v[i].end(),std::inserter(myset)); // This is not correct but what is the right way ? // and also here, I want to search for a particular vector if it exists in the table. for ex. the second row of vector v. } return 0; } I'm not sure how to insert and look up a vector in a set. So if nybody could guide me, it will be helpful. Thanks

    Read the article

  • Sort a Vector of custom objects

    - by user307818
    I'm trying to sort a Vector in java but my Vector is not a vector of int, it is a vector of objects the object is: public MyObject() { numObj = 0; price = new Price(); pax = new Pax(); } so I have a Vector of MyObject and I want to order it by numObject, how do i do it, I'm new in java? Thank you so much for all your help.

    Read the article

  • sort a custum Vector of objects

    - by user307818
    I'm trying to sort a Vector in java but my Vector is not a vector of int, it is a vector of objects the object is : public MyObject() { numObj = 0; price = new Price(); pax = new Pax(); } so I have a Vector of MyObject and I want to order it by numObject, how do i do it, i'm new in java? thank you so much for all your help

    Read the article

  • Calculating the 2D edge normals of a triangle

    - by Kazade
    What's a reliable way to calculate a 2D normal vector for each edge of a triangle, so that each normal is pointing outwards from the triangle? To clarify, given any triangle - for each edge (e.g p2-p1), I need to calculate a 2D normal vector pointing away from the triangle at right angles to the edge (for simplicity we can assume that the points are being specified in an anti-clockwise direction). I've coded a couple of hacky attempts, but I'm sure I'm overlooking some simple method and Google isn't being that helpful today - that and I haven't had my daily caffeine yet!

    Read the article

  • Finding vectors with two points

    - by Christian Careaga
    We're are trying to get the direction of a projectile but we can't find out how For example: [1,1] will go SE [1,-1] will go NE [-1,-1] will go NW and [-1,1] will go SW we need an equation of some sort that will take the player pos and the mouse pos and find which direction the projectile needs to go. Here is where we are plugging in the vectors: def update(self): self.rect.x += self.vector[0] self.rect.y += self.vector[1] Then we are blitting the projectile at the rects coords.

    Read the article

  • Intelligence as a vector quantity

    - by Senthil Kumaran
    I am reading this wonderful book called "Coders at Work: Reflections on the Craft of Programming" by Peter Seibel and I am at part wherein the conversation is with Joshua Bloch and I found this answer which is an important point for a programmer. The paragraph, goes something like this. There's this problem, which is, programming is so much of an intellectual meritocracy and often these people are the smartest people in the organization; therefore they figure they should be allowed to make all the decisions. But merely the fact they are the smartest people in the organization does not mean that they should be making all the decisions, because intelligence is not a scalar quantity; it's a vector quantity. Here at the last sentence, I fail to get the insight which is he trying to share. Can someone explain it in a little further as what he means by a vector quantity, possibly trying to present the same insight. Further down, I get the point that he is not taking about having an organization where non-technical people (sometimes clueless) can be managers of the technical people for some reason that they can spend more time to write emails well, because the very next statement following the above paragraph was. And if you lack empathy or emotional intelligence, then you shouldn't be designing APIs or GUIs or languages. I understand that he is saying that in Software engineering, programmers should know how the users will see their product and design for them. I felt the above paragraph was very interesting.

    Read the article

  • Offset Forward vector of object based on Rotation

    - by Taylor
    I'm using the Bullet 3D physics engine in a iOS application running openGL ES 1.1 Currently I'm accepting info from the gyroscope to allow the user to "look around" a 3d world that follows a bouncing ball (note: it only takes in the yaw to look around 360 degrees). Im also accepting information from the accelerometer based on the tilt to push the ball. As of right now, to move forward, the user tilts the devise forward (using the accelerometer); to move to the right, the user tilts the devise to the right and so on. The forward vector is currently along it's local Z-axis. The problem is that I want to change the ball bounce based on where the user has changed the view. If I change the view, the ball bounces in the fixed direction. I want to change the forward facing direction so that when a user changes the view (say to the look at the right of the world, the user rotates the device), tilting the devise forward will result in a forward force in that direction. Basically, I want the forward vector to take the rotation into consideration. Sorry if I didn't explain the issue well enough, its kind of confusing to write down.

    Read the article

  • Efficiently separating Read/Compute/Write steps for concurrent processing of entities in Entity/Component systems

    - by TravisG
    Setup I have an entity-component architecture where Entities can have a set of attributes (which are pure data with no behavior) and there exist systems that run the entity logic which act on that data. Essentially, in somewhat pseudo-code: Entity { id; map<id_type, Attribute> attributes; } System { update(); vector<Entity> entities; } A system that just moves along all entities at a constant rate might be MovementSystem extends System { update() { for each entity in entities position = entity.attributes["position"]; position += vec3(1,1,1); } } Essentially, I'm trying to parallelise update() as efficiently as possible. This can be done by running entire systems in parallel, or by giving each update() of one system a couple of components so different threads can execute the update of the same system, but for a different subset of entities registered with that system. Problem In reality, these systems sometimes require that entities interact(/read/write data from/to) each other, sometimes within the same system (e.g. an AI system that reads state from other entities surrounding the current processed entity), but sometimes between different systems that depend on each other (i.e. a movement system that requires data from a system that processes user input). Now, when trying to parallelize the update phases of entity/component systems, the phases in which data (components/attributes) from Entities are read and used to compute something, and the phase where the modified data is written back to entities need to be separated in order to avoid data races. Otherwise the only way (not taking into account just "critical section"ing everything) to avoid them is to serialize parts of the update process that depend on other parts. This seems ugly. To me it would seem more elegant to be able to (ideally) have all processing running in parallel, where a system may read data from all entities as it wishes, but doesn't write modifications to that data back until some later point. The fact that this is even possible is based on the assumption that modification write-backs are usually very small in complexity, and don't require much performance, whereas computations are very expensive (relatively). So the overhead added by a delayed-write phase might be evened out by more efficient updating of entities (by having threads work more % of the time instead of waiting). A concrete example of this might be a system that updates physics. The system needs to both read and write a lot of data to and from entities. Optimally, there would be a system in place where all available threads update a subset of all entities registered with the physics system. In the case of the physics system this isn't trivially possible because of race conditions. So without a workaround, we would have to find other systems to run in parallel (which don't modify the same data as the physics system), other wise the remaining threads are waiting and wasting time. However, that has disadvantages Practically, the L3 cache is pretty much always better utilized when updating a large system with multiple threads, as opposed to multiple systems at once, which all act on different sets of data. Finding and assembling other systems to run in parallel can be extremely time consuming to design well enough to optimize performance. Sometimes, it might even not be possible at all because a system just depends on data that is touched by all other systems. Solution? In my thinking, a possible solution would be a system where reading/updating and writing of data is separated, so that in one expensive phase, systems only read data and compute what they need to compute, and then in a separate, performance-wise cheap, write phase, attributes of entities that needed to be modified are finally written back to the entities. The Question How might such a system be implemented to achieve optimal performance, as well as making programmer life easier? What are the implementation details of such a system and what might have to be changed in the existing EC-architecture to accommodate this solution?

    Read the article

  • How do I intiailize the vector I have defined in my header file?

    - by FrankTheTank
    I have the following in my Puzzle.h class Puzzle { private: vector<int> puzzle; public: Puzzle() : puzzle (16) {} bool isSolved(); void shuffle(vector<int>& ); }; and then my Puzzle.cpp looks like: Puzzle::Puzzle() { // Initialize the puzzle (0,1,2,3,...,14,15) for(int i = 0; i <= puzzle.size(); i++) { puzzle[i] = i; } } // ... other methods Am I using the initiailizer list wrong in my header file? I would like to define a vector of ints and initialize its size to that of 16. How should I do this? G++ Output: Puzzle.cpp:16: error: expected unqualified-id before ')' token Puzzle.cpp: In constructor `Puzzle::Puzzle()': Puzzle.cpp:16: error: expected `)' at end of input Puzzle.cpp:16: error: expected `{' at end of input Puzzle.cpp: At global scope: Puzzle.cpp:24: error: redefinition of `Puzzle::Puzzle()' Puzzle.cpp:16: error: `Puzzle::Puzzle()' previously defined here

    Read the article

  • Calculate lookat vector from position and Euler angles

    - by Jaap
    I've implemented an FPS style camera, with the camera consisting of a position vector, and Euler angles pitch and yaw (x and y rotations). After setting up the projection matrix, I then translate to camera coordinates by rotating, then translating to the inverse of the camera position: // Load projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Set perspective gluPerspective(m_fFOV, m_fWidth/m_fHeight, m_fNear, m_fFar); // Load modelview matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Position camera glRotatef(m_fRotateX, 1.0, 0.0, 0.0); glRotatef(m_fRotateY, 0.0, 1.0, 0.0); glTranslatef(-m_vPosition.x, -m_vPosition.y, -m_vPosition.z); Now I've got a few viewports set up, each with its own camera, and from every camera I render the position of the other cameras (as a simple box). I'd like to also draw the view vector for these cameras, except I haven't a clue how to calculate the lookat vector from the position and Euler angles. I've tried to multiply the original camera vector (0, 0, -1) by a matrix representing the camera rotations then adding the camera position to the transformed vector, but that doesn't work at all (most probably because I'm way off base): vector v1(0, 0, -1); matrix m1 = matrix::IDENTITY; m1.rotate(m_fRotateX, 0, 0); m1.rotate(0, m_fRotateY, 0); vector v2 = v1 * m1; v2 = v2 + m_vPosition; // add camera position vector glBegin(GL_LINES); glVertex3fv(m_vPosition); glVertex3fv(v2); glEnd(); What I'd like is to draw a line segment from the camera towards the lookat direction. I've looked all over the place for examples of this, but can't seem to find anything. Thanks a lot!

    Read the article

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