vectors

How to get Yaw, Pitch and Roll from a 3D vector

Hi all, I have a direction vector that applied to a position gives me the point at which the camera should look. How can I get from that yaw, pitch and roll in order to use glRotatef properly? Thanks in advance ...

J2me - Arrays vs vector ?

if we have to implementations of string split for j2me, one returns vector and the other returns array , in terms of performance on hand held devices which one is the best choice ? ...

Sharing same vector control between different places

Hi everyone, I'm trying to implement the following: I have an Items Manager, that has an Item class inside. Item class can store two possible visual representations of it - BitmapImage(bitmap) and UserControl(vector). Then later, in the game, I need to share the same image or vector control between all possible places it takes place. F...

Need help with implementing collision detection using the Separating Axis Theorem

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 n...

Where can I buy game sprites and tiles?

Yes, I'd prefer to buy them instead of using "free" or "free" with some kind of weird license. Tried Google, but no luck and my fav RF graphics sites don't have any... :( ...

is it wasteful/bad design to use a vector/list where in most instances it will only have one element?

is it wasteful/bad design to use a vector/list where in most instances it will only have one element? example: class dragon { ArrayList<head> = new ArrayList<head> Heads; tail Tail = new tail(); body Body = new body(); dragon() { theHead=new head(); Heads.add(theHead); } void nod() { ...

accessing a vector from the back

Is there a way to access an element on a vector starting from the back? I want to access the second last element.currently I'm using the following to achieve that: myVector[myVector.size() - 2] but this seems slow and clunky, is there a better way? ...

Clojure Lazy Sequences that are Vectors

I have noticed that lazy sequences in Clojure seem to be represented internally as linked lists (Or at least they are being treated as a sequence with only sequential access to elements). Even after being cached into memory, access time over the lazy-seq with nth is O(n), not constant time as with vectors. ;; ...created my-lazy-seq here...

Deleting user-defined vectors - C++

Hi, I have 2 classes, say A & B. Class B has a destructor of its own. Within class A, I have a vector of pointers to objects of class B. The vector is as follows: vector<B*> vect; In the destructor for class A, how do I retrieve memory? If I cycle through the vector, do I retrieve each object and use delete on every retrieved object?...

How to store Sparse matrix for a matrix-vector multiply when some boundary condition values are known?

Hello all, I have a sparse matrix that represents a 3D rectangular space. Along some of the boundaries, I know what the value is going to be (it's a constant). The other boundaries may be reflective, differential, etc. Should I just set the problem up as if all the boundaries were say, differential, and then go back and set the nodes ...

Why is the code printing the last std::cout??

using namespace std; template<typename T> int f(vector<T> &v){ return v.size(); } template<typename T> class B{ public: int size(){ return v.size(); }; private: vector<T> v; }; int main(int argc, char** argv) { B<string> b; vector<string> v; for(int i=0; i<f<string>(v)-1; i++) std::cout <...

Fast lookup for dictionary vector to a given vector. High dimensions

I'm looking for an answer that scales, but for my specific purpose, I have a 48th dimension vector. This could be represented as an array of 48 integers all between 0 and 255. I have a large dictionary of these vectors, approximately 25 thousand of them. I need to be able to take a vector that may or may not be in my database, and qui...

AES CTR Test Vectors

I am implementing a small demo application which encrypts using AES CTR with OpenSSL is it possible to test the algorithm using different modes of operation test vectors for example testing the ECB vector in my application and check the result or is it restricted to ctr test vectors??? If it is restricted to test it with ctr can anybody ...

Visualize high dimensional field arrows?

Hi, I have a big list of tuples (a, b), where both a and b are 9-dimensional vectors from the same space. This essentially encodes states of a system and some transitions. I would like to visualize the field described by these tuples, as arrows pointing from a->b, either in 2D or 3D. One of my problems however is that this is not a wel...

How do I get the x or y angle of two vectors?

I know I can get the total angle of two vectors by the dot product of them both, but what if I just want to break down the angle into components of angle by X and angle by Y? ...

drawing on iphone

hello, I am trying to develop an iPhone application for children which will be able to draw characters on screen with touch and I want to know how to match the character drawn with good character of the alphabet. How will i compare the two shapes (drawing and existing) Any idea?? some code? ...

Efficiently typecast elements of a vector in Java

Is there a more efficient way (preferably O(1) rather than O(n) but at least faster to type) to typecast the elements of a vector than this? public Vector<String> typecastVector(Vector<Object> objects){ Vector<String> strings = new Vector<String>(); for(Object o : objects) strings.add((String) o); return strings; } ...

how to draw complex shapes on the html canvas tag with the best performance?

I am using the HTML canvas tag to draw around 3000, vector lines on a small area (900x500) the target platform is mobile which has inherently lower spec'd hardware. On my desktop I can make the 3000 vector lines render, using moveto and lineto in about 25ms. However on the mobile device it's more like 700ms which is significantly slower....

Vector algebra in functional

How to implement vector sum, using functional programming in python. This code work for n <100, but not for n > 1000. from itertools import * #n=10000 # do not try!!! n=100 twin=((i,i**2,i**3) for i in xrange(1,n+1)) def sum(x=0,y=0): return x+y def dubsum(x,y): return (reduce(sum,i) for i in izip(x,y) ) print [ i for i in r...

Generate a random vector inside a rectangle but not a circle?

I have a rectangle, and a circle inside that rectangle (that sits around the center of the rectangle). I want to generate a random 2-component vector that falls inside the rectangle, but not the circle. How can I do it? Edit: I'd prefer a method that i can use to generate a vector that meets these constraints without brute-forcing it. ...