vector

What are the dot and cross product of vectors?

I know how to do these mathematically but I don't actual know what they yield. I'v had formulas that required their use without actually knowing why they are required. How do they work in computer graphics? Thanks ...

sparse_vector template class: How do I clean it up?

I'm not sure if this is a good question or not — please close it if not. I set out to write (using boost::coordinate_vector as a starting point) a sparse_vector template class that efficiently implements a vector-like interface, but is sparse. It implements all the usual vector operations and a fast sparse iterator that iterates over t...

How can I avoid quality problems due to 3D in Flash CS4?

I am currently using Flash CS4 to make some sprites. The sprite is completely vector based and should therefore have good quality. However, once I apply some 3D properties to anything, it becomes very aliased. Is there some quality setting I'm missing? ...

Iterating over 2-dimensional STL vector c++

I'm currently trying to print out a history of movements for players in a game I am working on. At the end of each round every player has moved some amount in the positive or negative direction and this gets recorded as an int in the movement vector. Eventually I'm wanting to plot the directions moved vs time for each player but I'm havi...

C++ case multimap

I have a multimap defined by typedef std::pair<int, int> au_pair; //vertices typedef std::pair<int, int> acq_pair; //ch qlty specified by C typedef std::multimap<int, acq_pair> au_map; typedef au_map::iterator It_au; The no. of simulations depend on the size of the au_map. For eg: if the au_map.size() = 5 I will have C1, C2, C3, C4, C...

Why do vector indices in R start with 1, instead of 0?

What is the reason that vector indices in R start with 1, instead of the usual 0? Example: > arr<-c(10,20) > arr[0] numeric(0) > arr[1] [1] 10 > arr[2] [1] 20 Is it just that they want to store extra information about the vector and didn't know where to store it except as the vector's first element? ...

OpenGL quad from normal

Hi Is possible to draw a quad given its normal vector, a point that is center of the quad and the size of the quad? I know the equation of a plane with normal vector n=(a,b,c) passing through the point (x_0,y_0,z_0) is given by a(x-x_0)+b(y-y_0)+c(z-z_0)=0. (from here) But how to find the coordinate of the four vertex of the quad? T...

Compression in Scala

I'm working on Scala with VERY larg lists of Int (maybe large) and I need to compress them and to hold it in memory. The only requirement is that I can pull (and decompress) the first number on the list to work with, whithout touching the rest of the list. I have many good ideas but most of them translate the numbers to bits. Example: ...

Calculating 3d plane for two 3d vectors

If I have two vector coordinates representing positions on the surface of the earth where the center of the earth is (0,0,0) and the Up vector is (0,0,1); What is the best way to calculate a 3d plane that is running along the two vectors (the direction v2 - v1) but back by a set number of meters (just imagine a virtual clip plane that i...

Yet another Dynamic Array vs. std::vector, but...

...well, I got strange results! I was curious about the performance of std::vector vs. that of a dynamic array. Seeing as there are many questions on this subject already, I wouldn't have mentioned it if I didn't constantly get these 'contradictory' results: vector<int> is somehow faster than a new int[]! I always thought that if there ...

Zooming into the mouse position with a translation?

To zoom into the mouse position I was using: glTranslatef(current.ScalePoint.x,current.ScalePoint.y,0); glScalef(current.ScaleFactor,current.ScaleFactor,current.ScaleFactor); glTranslatef(-current.ScalePoint.x,-current.ScalePoint.y,0); so basically I translate to the new origin (the mouse position) then scale by the current sc...

Sort C++ Strings with multiple criteria

I need to sort a C++ std::vector<std::string> fileNames. The fileNames are labeled as such YYDDDTTTT_Z_SITE YY = Year (i.e 2009 = 09, 2010 = 10) DDD = Day of the year (i.e 1 January = 001, 31 December = 365) TTTT = Time of the day (i.e midnight = 0000, noon = 1200) ZONE = Will be either E or W SITE = Four letter site n...

Convert a quadratic bezier to a cubic?

What is the algorithm to convert a quadratic bezier (with 3 points) to a cubic one (with 4 points) Thanks ...

Does GetPath() return cubic or quadratic bezier control points?

Microsoft's docs say: Specifies that the corresponding point in lpPoints is a control point or ending point for a Bèzier curve. PT_BEZIERTO values always occur in sets of three. The point in the path immediately preceding them defines the starting point for the Bèzier curve. The first two PT_BEZIERTO points are...

How does c++ std::vector work?

How does adding and removing elements "rescale" the data? How is the size of the vector calculated (I believe it is kept track of)? Any other additional resources to learn about vectors would be appreciated. ...

Will a class recall its constructor when pushed in a std::vector?

if for example I do: FOO foo; foovect.push_back(foo); where FOO is a class with a default constructor. Will the constructor be called only when foo is put on the stack, or is it called again when pushed into the std::vector? Thanks I'm doing: OGLSHAPE::OGLSHAPE(void) { glGenBuffersARB(GL_ARRAY_BUFFER_ARB,&ObjectVBOInt); } ...

non-resizeable vector/array of non-reassignable but mutable members?

Is there a way to make a non-resizeable vector/array of non-reassignable but mutable members? The closest thing I can imagine is using a vector<T *> const copy constructed from a temporary, but since I know at initialization how many of and exactly what I want, I'd much rather have a block of objects than pointers. Is anything like wha...

Strange CUDA behavior in vector multiplication program

Hi, I'm having some trouble with a very basic CUDA program. I have a program that multiplies two vectors on the Host and on the Device and then compares them. This works without a problem. What's wrong is that I'm trying to test different number of threads and blocks for learning purposes. I have the following kernel: __global__ void m...

How can I do this for cubic beziers?

Right now i'm creating polygons with bezier handles. It's working well, except right now I always do something like this: for(float i = 0; i < 1; i += 0.04) { interpolate A, a.handle to B.handle, B at time i } The problem is no matter how short the distance or long the distance between point A and B, it always produces the same amo...

vector vs set in java

which one do you prefer? i want to make a finite automata in java,. it's more efficient using vector or set??? ...