Search Results

Search found 4092 results on 164 pages for 'initialization vector'.

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

  • Calculating up-vector to avoid gimbal lock using euler angles

    - by jessejuicer
    I wish to orbit a camera around a sphere, yet the problem is that when the camera rotates so that it is at the north pole (and pointing down) or the south pole (and pointing up) of the sphere the camera doesn't handle itself very well. It spins rapidly until arriving 180 degrees in the opposite direction. I believe this is known as gimbal lock. I understand you can avoid this problem using quaternions. But I also read in another forum that it's possible to avoid this easily using euler angles as well. Which I would prefer to do. It was said that all you need to do is "calculate a proper up-vector every frame, and that avoids the problem entirely." Well, I tried aligning the up-vector with the vertical axis of the camera whenever the camera changed orientation, but this didn't seem to work. Meaning that the up-vector followed exactly the orientation of the camera's y-axis (or it's up vector), instead of using a constant up-vector aligned to the up-vector of the world (0, 1, 0). How exactly do I go about calculating a proper up-vector as my camera orientation changes to avoid the gimbal lock problem mentioned above?

    Read the article

  • How to solve lazy initialization exception using JPA and Hibernate as provider

    - by rupertin
    I am working on a project for a customer who wants to use lazy initialization. They always get "lazy initialization exception" when mapping classes with the default lazy loading mode. @JoinTable(name = "join_profilo_funzionalita", joinColumns = {@JoinColumn(name = "profilo_id", referencedColumnName = "profilo_id")}, inverseJoinColumns = {@JoinColumn(name = "funzionalita_id", referencedColumnName = "funzionalita_id")}) //@ManyToMany(fetch=FetchType.EAGER) - no exceptions if uncommented @ManyToMany private Collection<Funzionalita> funzionalitaIdCollection; Is there a standard pattern using JPA classes to avoid this error? Snippets are welcome, thanks a lot for your time.

    Read the article

  • initialization of objects in c++

    - by Happy Mittal
    I want to know, in c++, when does the initialization of objects take place? Is it at the compile time or link time? For ex: //file1.cpp extern int i; int j=5; //file2.cpp ( link with file1.cpp) extern j; int i=10; Now, what does compiler do : according to me, it allocates storage for variables. Now I want to know : does it also put initialization value in that storage or is it done at link time?

    Read the article

  • Double Free inside of a destructor upon adding to a vector

    - by Shawn B
    Hey, I am working on a drum machine, and am having problems with vectors. Each Sequence has a list of samples, and the samples are ordered in a vector. However, when a sample is push_back on the vector, the sample's destructor is called, and results in a double free error. Here is the Sample creation code: class XSample { public: Uint8 Repeat; Uint8 PlayCount; Uint16 Beats; Uint16 *Beat; Uint16 BeatsPerMinute; XSample(Uint16 NewBeats,Uint16 NewBPM,Uint8 NewRepeat); ~XSample(); void GenerateSample(); void PlaySample(); }; XSample::XSample(Uint16 NewBeats,Uint16 NewBPM,Uint8 NewRepeat) { Beats = NewBeats; BeatsPerMinute = NewBPM; Repeat = NewRepeat-1; PlayCount = 0; printf("XSample Construction\n"); Beat = new Uint16[Beats]; } XSample::~XSample() { printf("XSample Destruction\n"); delete [] Beat; } And the 'Dynamo' code that creates each sample in the vector: class XDynamo { public: std::vector<XSample> Samples; void CreateSample(Uint16 NewBeats,Uint16 NewBPM,Uint8 NewRepeat); }; void XDynamo::CreateSample(Uint16 NewBeats,Uint16 NewBPM,Uint8 NewRepeat) { Samples.push_back(XSample(NewBeats,NewBPM,NewRepeat)); } Here is main(): int main() { XDynamo Dynamo; Dynamo.CreateSample(4,120,2); Dynamo.CreateSample(8,240,1); return 0; } And this is what happens when the program is run: Starting program: /home/shawn/dynamo2/dynamo [Thread debugging using libthread_db enabled] XSample Construction XSample Destruction XSample Construction XSample Destruction *** glibc detected *** /home/shawn/dynamo2/dynamo: double free or corruption (fasttop): 0x0804d008 *** However, when the delete [] is removed from the destructor, the program runs perfectly. What is causing this? Any help is greatly appreciated.

    Read the article

  • Vector insert() causes program to crash

    - by wrongusername
    This is the first part of a function I have that's causing my program to crash: vector<Student> sortGPA(vector<Student> student) { vector<Student> sorted; Student test = student[0]; cout << "here\n"; sorted.insert(student.begin(), student[0]); cout << "it failed.\n"; ... It crashes right at the sorted part because I can see "here" on the screen but not "it failed." The following error message comes up: Debug Assertion Failed! (a long path here...) Expression: vector emplace iterator outside range For more information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. I'm not sure what's causing the problem now, since I have a similar line of code elsewhere student.insert(student.begin() + position(temp, student), temp); that does not crash (where position returns an int and temp is another declaration of a struct Student). What can I do to resolve the problem, and how is the first insert different from the second one?

    Read the article

  • Get location of element you just pushed into vector C++

    - by Satchmo Brown
    I am curious about how pushing back into a vector works. I want a way to push back an element and then be able to add it's location in the vector to a double array serving as a type of map. Something like this: // Create a bomb Bomb b; b.currentTime = SDL_GetTicks(); b.explodeTime = SDL_GetTicks() + 3000; b.owner = player; b.power = 2; b.x = x; b.y = y; bombVec.push_back(b); bombs[y][x] = THIS_IS_WHAT_I_WANT; This way when I explode the bomb, I can check the map and then have an ID in the vector to deal with. Every non bomb square will have a -1. Also, just curious. Imagine I have 3 elements in a vector. I delete the second one and then add another. Does the new element go in the same location as the one that was deleted? Thanks!

    Read the article

  • Loading data from file to Vector structure

    - by owca
    I'm trying to parse through fixed-width formatted file extracting x,y values of points from it, and then storing them in int[] array inside a Vector. Text file looks as follows : 0006 0015 0125 0047 0250 0131 That's the code : Vector<int[]> vc = new Vector<int[]>(); try { BufferedReader file = new BufferedReader(new FileReader("myfile.txt")); String s; int[] vec = new int[2]; while ((s = file.readLine()) != null) { vec[0] = Integer.parseInt(s.substring(0, 4).trim()); vec[1] = Integer.parseInt(s.substring(5, 8).trim()); vc.add(vec); } file.close(); } catch (IOException e) { } for(int i=0; i<vc.size(); i++){ for(int j=0; j<2; j++){ System.out.println(vc.elementAt(i)[j]); } } But the output shows only last line. 250 131 250 131 250 131 Should I somehow use Vector.nextElement() here to get all my data ?

    Read the article

  • C++ std::vector memory/allocation

    - by aaa
    from a previous question about vector capacity, http://stackoverflow.com/questions/2663170/stdvector-capacity-after-copying, Mr. Bailey said: In current C++ you are guaranteed that no reallocation occurs after a call to reserve until an insertion would take the size beyond the value of the previous call to reserve. Before a call to reserve, or after a call to reserve when the size is between the value of the previous call to reserve and the capacity the implementation is allowed to reallocate early if it so chooses. So, if I understand correctly, in order to assure that no relocation happens until capacity is exceeded, I must do reserve twice? can you please clarify it? I am using vector as a memory stack like this: std::vector<double> memory; memory.reserve(size); memory.insert(memory.end(), matrix.data().begin(), matrix.data().end()); // smaller than size size_t offset = memory.size(); memory.resize(memory.capacity(), 0); I need to guarantee that relocation does not happen in the above. thank you. ps: I would also like to know if there is a better way to manage memory stack in similar manner other than vector

    Read the article

  • Release Candidates of Application Initialization and Dynamic IP Restrictions Released

    - by The Official Microsoft IIS Site
    Two new Release Candidates for the following IIS Extensions have been released today: Application Initialization for IIS 7.5 (the replacement for the previously released Application Warmup beta extension) Dynamic IP Restrictions for IIS7/7.5 Application Initialization for IIS 7.5 Application Initialization is a feature which is coming in IIS 8.0 and is now also available for IIS 7.5 (please note this feature is not available for IIS 7.0).   This module helps to eliminate the lack of feedback...(read more)

    Read the article

  • android saveinstance saving vector datatypes

    - by Javadid
    hi friends, I am making an application which is currently working perfectly but with only 1 problem... As we all know that the activity is destroyed and recreated when user changes the orientation of the phone... my activity needs to save a vector full of objects wen the activity is recreated... i checked the OnSaveInstance() method and found that there is no way a vector can be stored... Does any1 have a suggestion for storing vector so that i can retrieve it on recreation of Activity??? Any help will be appreciated... Thanx...

    Read the article

  • Boost::Container::Vector with Enum Template Argument - Not Legal Base Class

    - by CuppM
    Hi, I'm using Visual Studio 2008 with the Boost v1.42.0 library. If I use an enum as the template argument, I get a compile error when adding a value using push_back(). The compiler error is: 'T': is not a legal base class and the location of the error is move.hpp line 79. #include <boost/interprocess/containers/vector.hpp> class Test { public: enum Types { Unknown = 0, First = 1, Second = 2, Third = 3 }; typedef boost::container::vector<Types> TypesVector; }; int main() { Test::TypesVector o; o.push_back(Test::First); return 0; } If I use a std::vector instead it works. And if I resize the Boost version first and then set the values using the [] operator it also works. Is there some way to make this work using push_back()?

    Read the article

  • Sorting a vector of (double precision) reals and obtain their order

    - by Philipp
    Hello everyone, in C++ would like to sort a lengthy (2^20) vector of reals, obviously sort() does the trick. Having used R before I was used to the nice order() function which yields the permutation that leads to the sorted vector. Probably someone has done this in C++, maybe it's just my weak google-Fu that prevents me from finding it. And yeah, obivously my C++ newbness could stop me from spotting something straightforward. Example: x = {24, 55, 22, 1} then the permutation perm = {3, 2, 0, 1} maps the original x to the sorted x in ascending order. I can probably implement some bubble sort which does not only sort x but performs the same transpositions on the vector {0,1,2,...} and outputs both, but I believe someone must have thought about it and especially have done it efficiently. Thank you very much, Philipp

    Read the article

  • Method for exporting drawn flash/flex UIComponent to vector based print file

    - by eshowcase
    Hi, I am creating a flex application where I am using the built in graphics package of flex 3 to draw shapes and things to a UIComponent. I want to be able to export this vector image UIComponent to a vector based file, pdf, eps etc. Are there any tools, libraries, or methods for doing so? I looked at AlivePDF - which works very slick, but its output is effectively a snapshot of the UIComponent drawn out as a bitmap to the PDF. I want true vector output, as this image is for print, needs to be able to scale and be color correct. I read somewhere that it may be possible with Adobe Live Cycle, but in looking at the documentation I'm not sure how to use it. Another possibility is to submit the final image parameters to a server-side PHP script that would re-generate the image in SVG format. But as I understand SVG is not ideal for print, and this is lots of extra work. Any thoughts, ideas, methods? Thanks!

    Read the article

  • vector segmentation fault

    - by user1849298
    I have a problem with the segmentation fault. Look: #include<fstream> using namespace std; int main(){ int n,i,vector[10001],vectorcopy[10001]; ifstream in("program.in"); ofstream out("program.out"); in>>n; for(i=1;i<=n;i++){ in>>vector[i]; vectorcopy[i]=vector[i]; } return 0;} And the debugger says: Program recived signal SIGSEGV, Segmentation fault Please, tell me what to do!

    Read the article

  • Counting Values in R Vector

    - by GTyler
    I have a large vector of percentages (0-100) and I am trying to count how many of them are in specific 20% buckets (<20, 20-40, 40-60,60-80,80-100). The vector has length 129605 and there are no NA values. Here's my code: x<-c(0,0,0,0,0) for(i in 1: length(mail_return)) { if (mail_return[i]<=20) { x[1] = x[1] + 1 } if (mail_return[i]>20 && mail_return[i]<=40) { x[2] = x[2] + 1 } if (mail_return[i]>40 && mail_return[i]<=60) { x[3] = x[3] + 1 } if (mail_return[i]>60 && mail_return[i]<=80) { x[4] = x[4] + 1 } else { x[5] = x[5] + 1 } } But sum(x) is giving me length 133171. Shouldn't it be the length of the vector, 129605? What's wrong?

    Read the article

  • c++ Sorting a vector based on values of other vector, or what's faster?

    - by pollux
    Hi, There are a couple of other posts about sorting a vector A based on values in another vector B. Most of the other answers tell to create a struct or a class to combine the values into one object and use std::sort. Though I'm curious about the performance of such solutions as I need to optimize code which implements bubble sort to sort these two vectors. I'm thinking to use a vector<pair<int,int>> and sort that. I'm working on a blob-tracking application (image analysis) where I try to match previously tracked blobs against newly detected blobs in video frames where I check each of the frames against a couple of previously tracked frames and of course the blobs I found in previous frames. I'm doing this at 60 times per second (speed of my webcam). Any advice on optimizing this is appreciated. The code I'm trying to optimize can be shown here: http://code.google.com/p/projectknave/source/browse/trunk/knaveAddons/ofxBlobTracker/ofCvBlobTracker.cpp?spec=svn313&r=313 Thanks

    Read the article

  • Java: How to store Vector<String[]> in XML (or save in any other way)

    - by hatboysam
    Basically I have a proof-of-concept application that is a digital recipe book. Each Recipe is an object and each object has, among other fields, a Vector containing arrays. The Vector is the list of all ingredients in the Recipe while each ingredient has an array showing the name of the ingredient, the amount, and the unit for that amount. I want to save each Recipe to XML so that they can be accessed by the user. How can I store a Vector of String arrays in XML or any other sort of file so that it can later be recalled and accessed?

    Read the article

  • C++ Vector of vectors

    - by xbonez
    I have a class header file called Grid.h that contains the following 2 private data object: vector<int> column; vector<vector<int>> row; And a public method whose prototype in Grid.h is such: int getElement (unsigned int& col, unsigned int& row); The definition of above mentioned function is defined as such in Grid.cpp: int getElement (unsigned int& col, unsigned int& row) { return row[row][col] ; } When I run the program, I get this error: error C2109: subscript requires array or pointer type Whats going wrong?

    Read the article

  • C++ vector that *doesn't* initialize its members?

    - by Mehrdad
    I'm making a C++ wrapper for a piece of C code that returns a large array, and so I've tried to return the data in a vector<unsigned char>. Now the problem is, the data is on the order of megabytes, and vector unnecessarily initializes its storage, which essentially turns out to cut down my speed by half. How do I prevent this? Or, if it's not possible -- is there some other STL container that would avoid such needless work? Or must I end up making my own container? (Pre-C++11) Note: I'm passing the vector as my output buffer. I'm not copying the data from elsewhere.

    Read the article

  • Methods for Lazy Initialization with properties

    - by Stuart Pegg
    I'm currently altering a widely used class to move as much of the expensive initialization from the class constructor into Lazy Initialized properties. Below is an example (in c#): Before: public class ClassA { public readonly ClassB B; public void ClassA() { B = new ClassB(); } } After: public class ClassA { private ClassB _b; public ClassB B { get { if (_b == null) { _b = new ClassB(); } return _b; } } } There are a fair few more of these properties in the class I'm altering, and some are not used in certain contexts (hence the Laziness), but if they are used they're likely to be called repeatedly. Unfortunately, the properties are often also used inside the class. This means there is a potential for the private variable (_b) to be used directly by a method without it being initialized. Is there a way to make only the public property (B) available inside the class, or even an alternative method with the same initialized-when-needed? This is reposted from Programmers (not subjective enough apparently): http://programmers.stackexchange.com/questions/34270/best-methods-for-lazy-initialization-with-properties

    Read the article

  • Thread-safe initialization of function-local static const objects

    - by sbi
    This question made me question a practice I had been following for years. For thread-safe initialization of function-local static const objects I protect the actual construction of the object, but not the initialization of the function-local reference referring to it. Something like this: namspace { const some_type& create_const_thingy() { lock my_lock(some_mutex); static const some_type the_const_thingy; return the_const_thingy; } } void use_const_thingy() { static const some_type& the_const_thingy = create_const_thingy(); // use the_const_thingy } The idea is that locking takes time, and if the reference is overwritten by several threads, it won't matter. I'd be interested if this is safe enough in practice? safe according to The Rules? (I know, the current standard doesn't even know what "concurrency" is, but what about trampling over an already initialized reference? And do other standards, like POSIX, have something to say that's relevant to this?) For the inquiring minds: Many such function-local static const objects I used are maps which are initialized from const arrays upon first use and used for lookup. For example, I have a few XML parsers where tag name strings are mapped to enum values, so I could later switch over the tags enum values.

    Read the article

  • Preferred way of application initialization

    - by lisak
    Do you guys have your own little framework for project startups ? I mean, every time one needs to do the same things at the beginning: Context initialization - ideally after arguments are processed. Sometimes without interactive user input, sometimes with input reader. Sometimes we need to load properties, sometimes not. Then we need to get a class out of context and run its method. Programming....programming until writing shell script to place everything on classpath. It's true that it differs according to the actual needs. But it seems to me, that I'm doing always almost the same, again and again from the scratch. Sometimes I realize that I'm postponing my work just because I don't want to do these annoying startups. It would be great if there was some kind of universal Main class doing reflection to specified bean, context initialization, argument parsing, interactive user input reading and have the programmer do the important things...All setup might be done via spring configuration. I think I'll have to do it by myself. I'd appreciate your ideas

    Read the article

  • C++ Suppress Automatic Initialization and Destruction

    - by Travis G
    How does one suppress the automatic initialization and destruction of a type? While it is wonderful that T buffer[100] automatically initializes all the elements of buffer, and destroys them when they fall out of scope, this is not the behavior I want. #include <iostream> static int created = 0, destroyed = 0; struct S { S() { ++created; } ~S() { ++destroyed; } }; template <typename T, size_t KCount> class Array { private: T m_buffer[KCount]; public: Array() { // some way to suppress the automatic initialization of m_buffer } ~Array() { // some way to suppress the automatic destruction of m_buffer } }; int main() { { Array<S, 100> arr; } std::cout << "Created:\t" << created << std::endl; std::cout << "Destroyed:\t" << destroyed << std::endl; return 0; } The output of this program is: Created: 100 Destroyed: 100 I would like it to be: Created: 0 Destroyed: 0 My only idea is to make m_buffer some trivially constructed and destructed type like char and then rely on operator[] to wrap the pointer math for me, although this seems like a horribly hacked solution. Another solution would be to use malloc and free, but that gives a level of indirection that I do not want.

    Read the article

  • Perturb vector by some angle

    - by Myx
    Hello: I have a unit vector in 3D space whose direction I wish to perturb by some angle within the range 0 to theta, with the position of the vector remaining the same. What is a way I can accomplish this? Thanks.

    Read the article

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