Search Results

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

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

  • Split vector vs matrix notation for transformation

    - by seahorse
    Some rendering engines like Ogre prefer to use a individual vector based notation for transformations like the following Split vector notation: Net Transformation is represented by Scale vector = sx, sy, sz Transformation vector = tx, ty, tz Rotation Quaternion Vector = w,x,y,z Matrix notation: There are other engines which simply use a net combined transformation matrix. What are the advantages of the first notation over the second? Also for animation interpolation does it work in the first notation that we interpolate across the individual components and use the interpolated parts to get the net transformation? Is this another advantage?

    Read the article

  • When to use an Array vs When to use a Vector, when dealing with GameObjects?

    - by user32465
    I understand that from other answers, Arrays and Vectors are the best choices. Many on SE claim that Linked Lists and Maps are bad for video game programming. I understand that for the most part, I can use Arrays. However, I don't really understand exactly when to use Vectors over Arrays. Why even use Vectors? Wouldn't it be best if I simply always used an Array, that way I know how much memory my game needs? Specifically my game would only ever load a single "Map" area of tiles, such as Map[100][100], so I could very easily have an array of GameObjectContainer GameObjects[100][100], which would reserve an entire map's worth of possible gameobjects, correct? So why use a Vector instead? Memory is quite large on modern hardware.

    Read the article

  • What would be a good game making engine supporting Vector images?

    - by Qqwy
    I want to create a simple platforming game, in which you are a square in a wonderful world. I would like this game to be able to be played in browsers. Basically I am searching for something similar to "Flixel", but with the following features: Support Vector Graphics Allow zooming/rotating objects without producing huge amounts of lag as soon as you are using more objects. (Because I want to rotate the map around the player) So in other words, preferably zoom the viewport/camera instead of the objects themselves. Does an engine like that exist?

    Read the article

  • Check if the vector is behind another or maybe opposite directions?

    - by Gilson
    I'm doing a network game and on the client side, i interpolate the client position with the server sent extrapolated position. The client has its own physics simulation wich is corrected by the server in steps. The problem is when it laggs and i 'kick' the ball, the server gets a delayed message and sends me the position backwards of the client position wich makes the ball goes back and forth. I want to ignore those and maybe compensate that on the server, not sure though. The problem is the clock difference on those case are 0.07ms or 0.10 ms wich isn't that high to ignore the message i guess. When i get the server position, i extrapolate with the clock interval * serverBallVelocity Can i check if my new ball server position is behind my actual ball vector position? I tried to use the dot product after normalized the two vectors to check if they are opposite but it ain't working properly. Any suggestions on checking that?

    Read the article

  • Convert a Unit Vector to a Quaternion

    - by Hmm
    So I'm very new to quaternions, but I understand the basics of how to manipulate stuff with them. What I'm currently trying to do is compare a known quaternion to two absolute points in space. I'm hoping what I can do is simply convert the points into a second quaternion, giving me an easy way to compare the two. What I've done so far is to turn the two points into a unit vector. From there I was hoping I could directly plug in the i j k into the imaginary portion of the quaternion with a scalar of zero. From there I could multiply one quaternion by the other's conjugate, resulting in a third quaternion. This third quaternion could be converted into an axis angle, giving me the degree by which the original two quaternions differ by. Is this thought process correct? So it should just be [ 0 i j k ]. I may need to normalize the quaternion afterwards, but I'm not sure about that. I have a bad feeling that it's not a direct mapping from a vector to a quaternion. I tried looking at converting the unit vector to an axis angle, but I'm not sure this would work, since I don't know what angle to give as an input.

    Read the article

  • Use a vector to index a matrix without linear index

    - by David_G
    G'day, I'm trying to find a way to use a vector of [x,y] points to index from a large matrix in MATLAB. Usually, I would convert the subscript points to the linear index of the matrix.(for eg. Use a vector as an index to a matrix in MATLab) However, the matrix is 4-dimensional, and I want to take all of the elements of the 3rd and 4th dimensions that have the same 1st and 2nd dimension. Let me hopefully demonstrate with an example: Matrix = nan(4,4,2,2); % where the dimensions are (x,y,depth,time) Matrix(1,2,:,:) = 999; % note that this value could change in depth (3rd dim) and time (4th time) Matrix(3,4,:,:) = 888; % note that this value could change in depth (3rd dim) and time (4th time) Matrix(4,4,:,:) = 124; Now, I want to be able to index with the subscripts (1,2) and (3,4), etc and return not only the 999 and 888 which exist in Matrix(:,:,1,1) but the contents which exist at Matrix(:,:,1,2),Matrix(:,:,2,1) and Matrix(:,:,2,2), and so on (IRL, the dimensions of Matrix might be more like size(Matrix) = (300 250 30 200) I don't want to use linear indices because I would like the results to be in a similar vector fashion. For example, I would like a result which is something like: ans(time=1) 999 888 124 999 888 124 ans(time=2) etc etc etc etc etc etc I'd also like to add that due to the size of the matrix I'm dealing with, speed is an issue here - thus why I'd like to use subscript indices to index to the data. I should also mention that (unlike this question: Accessing values using subscripts without using sub2ind) since I want all the information stored in the extra dimensions, 3 and 4, of the i and jth indices, I don't think that a slightly faster version of sub2ind still would not cut it..

    Read the article

  • Need to calculate rotation-vector from Sensor.TYPE_ORIENTATION data

    - by Sponge
    I need to calculate a rotation vector out of the data i get from Sensor.TYPE_ORIENTATION. The sensor data is defined like this: the values have to be recalculated to become a correct 3d position: values[0]: Azimuth, angle between the magnetic north direction and the Y axis, around the Z axis (0 to 359). 0=North, 90=East, 180=South, 270=West values[1]: Pitch, rotation around X axis (-180 to 180), with positive values when the z-axis moves toward the y-axis. values[2]: Roll, rotation around Y axis (-90 to 90), with positive values when the x-axis moves away from the z-axis I need all three values like the Z axis value (from 0 to 360 degree). I tried a lot but cant figure out how to do this :/ i also tried to use Sensor.TYPE_ACCELEROMETER and Sensor.TYPE_MAGNETIC_FIELD to calculate this 3d vector on my own. here is the code: final float[] inR = new float[16]; // load inR matrix from current sensor data: SensorManager.getRotationMatrix(inR, null, gravityValues, geomagneticValues); float[] orientation = new float[3]; SensorManager.getOrientation(inR, orientation); mapMagAndAcclDataToVector(orientation); //here i do some *360 stuff orientetionChanged(orientation); //then the correct values are passed (in theorie) But this didn't work and i think it is much to complicated. So i bet there is a simple solution how to recalc the values of ensor.TYPE_ORIENTATION to make them a 3d rotation vector, but i just dont know how to do it. If you know the answer please tell me.

    Read the article

  • vector <T *> destructor

    - by Daniel.Z
    I have a class defined like: Class A { public: int num; A *parent; vector<A *> children; ... // constructor without parameters A(void) { this->num = 3; this->parent = 0; for (int i=0;i<num;++i) children.push_back(new A(this,num-1)); } // constructor with parameters A(A *a,int n) { this->num = n; this->children->parent = a; for (int i=0;i<num;++i) this->children.push_back(new A(this,this->num-1)); } }; now, the constructor works fine. there are some problem with destructor. currently, the destructor is defined as: A::~A(void) { if (this->parent!=0) this->parent = 0; for (int i=0;i<(int)children.size();++i) this->children[i]->~A(); vector <A *> ().swap(this->children); } but every time when I debug it, it will break at: void deallocate(pointer _Ptr, size_type) { // deallocate object at _Ptr, ignore size ::operator delete(_Ptr); } it looks like I cannot delete the pointer in the vector of this-children, is there any way that I can de-construct the class successfully?

    Read the article

  • STL vector performance

    - by iAdam
    STL vector class stores a copy of the object using copy constructor each time I call push_back. Wouldn't it slow down the program? I can have a custom linkedlist kind of class which deals with pointers to objects. Though it would not have some benefits of STL but still should be faster. See this code below: #include <vector> #include <iostream> #include <cstring> using namespace std; class myclass { public: char* text; myclass(const char* val) { text = new char[10]; strcpy(text, val); } myclass(const myclass& v) { cout << "copy\n"; //copy data } }; int main() { vector<myclass> list; myclass m1("first"); myclass m2("second"); cout << "adding first..."; list.push_back(m1); cout << "adding second..."; list.push_back(m2); cout << "returning..."; myclass& ret1 = list.at(0); cout << ret1.text << endl; return 0; } its output comes out as: adding first...copy adding second...copy copy The output shows the copy constructor is called both times when adding and when retrieving the value even then. Does it have any effect on performance esp when we have larger objects?

    Read the article

  • sum of square of each elements in the vector using for_each

    - by pierr
    Hi, As the function accepted by for_each take only one parameter (the element of the vector), I have to define a static int sum = 0 somewhere so that It can be accessed after calling the for_each . I think this is awkward. Any better way to do this (still use for_each) ? #include <algorithm> #include <vector> #include <iostream> using namespace std; static int sum = 0; void add_f(int i ) { sum += i * i; } void test_using_for_each() { int arr[] = {1,2,3,4}; vector<int> a (arr ,arr + sizeof(arr)/sizeof(arr[0])); for_each( a.begin(),a.end(), add_f); cout << "sum of the square of the element is " << sum << endl; } In Ruby, We can do it this way: sum = 0 [1,2,3,4].each { |i| sum += i*i} #local variable can be used in the callback function puts sum #=> 30 Would you please show more examples how for_each is typically used in practical programming (not just print out each element)? Is it possible use for_each simulate 'programming pattern' like map and inject in Ruby (or map /fold in Haskell). #map in ruby >> [1,2,3,4].map {|i| i*i} => [1, 4, 9, 16] #inject in ruby [1, 4, 9, 16].inject(0) {|aac ,i| aac +=i} #=> 30 EDIT: Thank you all. I have learned so much from your replies. We have so many ways to do the same single thing in C++ , which makes it a little bit difficult to learn. But it's interesting :)

    Read the article

  • Reversing strings in a vector using for_each and bind

    - by fmuecke
    Hi! I was wandering how it's possible to reverese strings that are contained in a vector using a single for_each command just in one "simple" line. Yea, I know it is easy with a custom functor, but I can't accept, that it can't be done using bind (at least I couldn't do it). #include <vector> #include <string> #include <algorithm> std::vector<std::string> v; v.push_back("abc"); v.push_back("12345"); std::for_each(v.begin(), v.end(), /*call std::reverse for each element*/); Edit: Thanks a lot for those funtastic solutions. However, the solution for me was not to use the tr1::bind that comes with the Visual Studio 2008 feature pack/SP1. I don't know why it does not work like expected but that's the way it is (even MS admits that it's buggy). Maybe some hotfixes will help. With boost::bind everything works like desired and is so easy (but sometimes relly messy:)). I really should have tried boost::bind in the first place...

    Read the article

  • Vector Usage in MPI(C++)

    - by lsk1985
    I am new to MPI programming,stiil learning , i was successful till creating the Derived data-types by defining the structures . Now i want to include Vector in my structure and want to send the data across the Process. for ex: struct Structure{ //Constructor Structure(): X(nodes),mass(nodes),ac(nodes) { //code to calculate the mass and accelerations } //Destructor Structure() {} //Variables double radius; double volume; vector<double> mass; vector<double> area; //and some other variables //Methods to calculate some physical properties Now using MPI i want to sent the data in the structure across the processes. Is it possible for me to create the MPI_type_struct vectors included and send the data? I tried reading through forums, but i am not able to get the clear picture from the responses given there. Hope i would be able to get a clear idea or approach to send the data PS: i can send the data individually , but its an overhead of sending the data using may MPI_Send/Recieve if we consider the domain very large(say 10000*10000)

    Read the article

  • (C++) Loading a file into a vector

    - by Alden
    This is probably a simple question, however I am new to C++ and I cannot figure this out. I am trying to load a binary file and load each byte to a vector. This works fine with a small file, but when I try to read larger than 410 bytes the program crashes and says: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I am using code::blocks on windows. This is the code: #include <iostream> #include <fstream> #include <vector> using namespace std; int main() { std::vector<char> vec; std::ifstream file; file.exceptions( std::ifstream::badbit | std::ifstream::failbit | std::ifstream::eofbit); file.open("file.bin"); file.seekg(0, std::ios::end); std::streampos length(file.tellg()); if (length) { file.seekg(0, std::ios::beg); vec.resize(static_cast<std::size_t>(length)); file.read(&vec.front(), static_cast<std::size_t>(length)); } int firstChar = static_cast<unsigned char>(vec[0]); cout << firstChar <<endl; return 0; } Thank you for your help!

    Read the article

  • const pod and std::vector

    - by Baz
    To get this code to compile: std::vector<Foo> factory() { std::vector<Foo> data; return data; } I have to define my POD like this: struct Foo { const int i; const int j; Foo(const int _i, const int _j): i(_i), j(_j) {} Foo(Foo& foo): i(foo.i), j(foo.j){} Foo operator=(Foo& foo) { Foo f(foo.i, foo.j); return f; } }; Is this the correct approach for defining a pod where I'm not interested in changing the pod members after creation? Why am I forced to define a copy constructor and overload the assignment operator? Is this compatible for different platform implementations of std::vector? Is it wrong in your opinion to have const PODS like this? Should I just leave them as non-const?

    Read the article

  • .net 4.0 concurrent queue dictionary

    - by freddy smith
    I would like to use the new concurrent collections in .NET 4.0 to solve the following problem. The basic data structure I want to have is a producer consumer queue, there will be a single consumer and multiple producers. There are items of type A,B,C,D,E that will be added to this queue. Items of type A,B,C are added to the queue in the normal manner and processed in order. However items of type D or E can only exist in the queue zero or once. If one of these is to be added and there already exists another of the same type that has not yet been processed then this should update that other one in-place in the queue. The queue position would not change (i.e. would not go to the back of the queue) after the update. Which .NET 4.0 classes would be best for this?

    Read the article

  • Why servlet halt a moment in concurrent request.

    - by Hlex
    I use Axis for webservice service. when more than 8 concurrent , there are some request halt randomly for about 30 seconds. I debug by log in every line and found from my code: public class foo{ void bar(){ a(); log.debug('exit from a'); } void a(){ log.debug('exit a'); } the time between "exit a" and "exit from a" are delay about 30 second. This is no reason. I try to increase web container thread pool , heap but didn't help ============== Enviroment websphere 6.1 Spring 2.5 , Hibernate 3 ,Axis 1.6.5 Min heap to 768 Max heap to 1024 Thread pool defult max to 300 Thread pool web container max to 500 ===============

    Read the article

  • Logic for controll concurrent in block or funciton

    - by Hlex
    1)My environment is web application, I accept large request from selvets. A) In some block/method i want to control concurrent to not greater than 5 B) if there are 5 request in that block , the new coming must wait up to 60 second then throws error C) if there are sleep/waiting request most then 30,throws error How I do this? 2)(Optional Question) from above I have to distribute control logic to all clustered host. I plan to use hazelcast to share the control logic (e.g. current counter) I see they provide BlockingQueue & ExectorService but I have no idea how to use in my case. Please recommend if you have idea.

    Read the article

  • Logic for controll concurrent in block/method

    - by Hlex
    1)My environment is web application, I develop servlet to receive request. A) In some block/method i want to control concurrent to not greater than 5 B) if there are 5 request in that block , the new coming must wait up to 60 second then throws error C) if there are sleep/waiting request more then 30, the 31th request will be throwed an error How I do this? 2)(Optional Question) from above I have to distribute control logic to all clustered host. I plan to use hazelcast to share the control logic (e.g. current counter) I see they provide BlockingQueue & ExectorService but I have no idea how to use in my case. Please recommend if you have idea.

    Read the article

  • Limiting the maximum number of concurrent requests django/apache

    - by Johan
    Hi, I have a django site that demonstrates the usage of a tool. One of my views takes a file as input and runs some fairly heavy computation trough an external python script and returns some output to the user. The tool runs fast enough to return the output in the same request though. I would however want to limit how many concurrent requests to this URL/view to keep the server from getting congested. Any tips on how i would go about doing this? The page in itself is very simple and the usage will be low.

    Read the article

  • ASP.NET - Exception logging approach for concurrent user scenario

    - by Whiskey-Tango-Foxtrot
    I am involved in designing a asp.net webforms application using .NET 3.5. I have a requirement where we need to log exceptions. What is the best approach for exception handling, given that there would be concurrent users for this application? Is there a need or possibility to log in exceptions at a user level? My support team in-charge wants to have a feature where the support team can get user specific log files. To give you a background, this application is currently on VB 6.0 and we are migrating it along with some enhancements. So, today the support personnel have a provision to get user specific log files.

    Read the article

  • Moving a point along a vector

    - by Chris
    Hello- I have a point defined by x,y and a vector defined by heading, speed. I am attempting to move the point x,y along this vector, at a distance of 'speed'. Below is the code I am currently using: self.x += self.speed * cos(self.heading); self.y += self.speed * sin(self.heading); Heading can be any angle in a full circle - 0 to 2p (0-360 degrees). The problem is the above code: Only moves along the x or y axis when angle is 0-270 for example, when the avatar is facing the top-right corner (45 degrees relative), it moves straight up. Does not move at all when angle is 270-360 heading, speed, X and Y are all doubles, and heading is reported by the user touching a direction-pad in the lower corner. I know the heading is correct because the avatar rotates to the correct direction, it is just the actual movement I am having problems with. Thanks for any help - Chris

    Read the article

  • Adding an Object to Vector loses Reference using Java?

    - by thechiman
    I have a Vector that holds a number of objects. My code uses a loop to add objects to the Vector depending on certain conditions. My question is, when I add the object to the Vector, is the original object reference added to the vector or does the Vector make a new instance of the object and adds that? For example, in the following code: private Vector numbersToCalculate; StringBuffer temp = new StringBuffer(); while(currentBuffer.length() > i) { //Some other code numbersToCalculate.add(temp); temp.setLength(0); //resets the temp StringBuffer } What I'm doing is adding the "temp" StringBuffer to the numbersToCalculate Vector. Should I be creating a new StringBuffer within the loop and adding that or will this code work? Thanks for the help! Eric

    Read the article

  • Simple vector program error

    - by Codeguru
    Hi iam new to c++ and iam trying out this vector program and i am getting the following error: error: conversion from test*' to non-scalar typetest' requested| Here is the code include include include include using namespace std; class test{ string s; vector <string> v; public: void read(){ ifstream in ("c://test.txt"); while(getline(in,s)) { v.push_back(s); } for(int i=0;i<v.size();i++) { cout<<v[i]<<"\n"; } } }; int main() { cout<<"Opening the file to read and displaying on the screen"< }

    Read the article

  • Function that copies into byte vector reverses values

    - by xeross
    Hey, I've written a function to copy any variable type into a byte vector, however whenever I insert something it gets inserted in reverse. Here's the code. template <class Type> void Packet::copyToByte(Type input, vector<uint8_t>&output) { copy((uint8_t*) &input, ((uint8_t*) &input) + sizeof(Type), back_inserter(output)); } Now whenever I add for example a uint16_t with the value 0x2f1f it gets inserted as 1f 2f instead of the expected 2f 1f. What am I doing wrong here ? Regards, Xeross

    Read the article

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