Search Results

Search found 1909 results on 77 pages for 'adjacency matrix'.

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

  • Passing an objects rotation down through its children

    - by MintyAnt
    In my topdown 2d game you have a player with a sword, like an old Zelda game. The sword is a seperate entity, and its collision box "rotates" around the player like an orbit, but always follows the player wherever he goes. The player and sword both have a vector2 heading. The sword is a weapon object that is attached to the character. In order to allow swinging in a direction, I have the following property inside sword (RotateCopy returns a copy of the mHeading after rotation) public Vector2 Heading { get { return mHeading.RotateCopy(mOwner.Rotation); } } This seems a bit messy to me, and slower than it could be. Is there a better way to "translate" the base/owner component rotations through to whatever component I am using, like this sword? Would using a rotation MATRIX be better? (Curretnly rotates by sin/cos) If so, how can I "add" up the matrices? Thank you.

    Read the article

  • Projecting onto different size screens by cropping

    - by Jason
    Hi, I am building a phone application which will display a shape on screen. The shape should look the same on different screen sizes. I. Decided the best way to do this is to show more of the background on larger screen keeping the shapes proportion the same on all screens. My problem is I am not sure how to achieve this, I can query the screen size at runtime and calculate how different it is from the six is designed for but I am not sure what to do with this value. What kind of projection should I use for my orthographic matrix an hour will I display more on larger screens and not loose information on smaller screens? Thanks, Jason.

    Read the article

  • Orthographic Projection with variable FOV

    - by cubrman
    We are building agame with orthographic view. The problem we face is the fact that with different resolution you can see different area of the game world. E.g. if you have higher resolution you can see more around you. To solve this we currently use a common scale factor that every model is scaled by, depending on resolution. But this has drawbacks when drawing shadows - I cannot set a higher view angle for the orthographic shadow camera, while when using the perspective shadow camera I get significantly worse shadow quality. So the question is is there any way to controll FOV when using orthographic projection, or, more specifically, what is the easiest way to scale the world uniformly up or down with orthographic projection matrix? I saw that in 3ds MAX you can control FOV for an orthographic camera I wonder how they implemented it.

    Read the article

  • Y Axis inverted on vertex output

    - by Yonathan Klijnsma
    I've got my project running and somehow it seems my vertex y components are inverted. 10 in the positive on Y goes down and 10 negative on the Y axis goes up. I can't find anything with the initialization and I am not doing any negative scaling in the view matrix. I've never had something like this happen before, does anyone have some tips or things to look for ? How I am sending verteces to the GPU ( Currently intermediate mode ) glVertex3f( x_pos_n, 10, z_pos ); I am using CG in the project but even without shaders the Y axis seems to be inverted.

    Read the article

  • Find largest rectangle containing all zero's in an N X N binary matrix

    - by Rajendra
    Given an N X N binary matrix (containing only 0's or 1's). How can we go about finding largest rectangle containing all 0's? Example: I 0 0 0 0 1 0 0 0 1 0 0 1 II->0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 <--IV 0 0 1 0 0 0 IV is a 6 X 6 binary matrix, return value in this case will be Cell 1: (2, 1) and Cell 2: (4, 4). Resulting sub-matrix can be square or rectangle. Return value can be size of the largest sub-matrix of all 0's also, for example, here 3 X 4.

    Read the article

  • obtain OpenGL camera(view) matrix from openCV findhomography

    - by user1828449
    I want to build an AR application on Android by opencv and opengl. I found GL_MODELVIEW can place camera and model in world coordinates like the following link I tried to load a simple model-view matrix by gl.glLoadMatrixf(newMat, 0); and it works so I want to draw 3d model on the top of my target image if i got the four corner points of the target image because model-view matrix is needed I want to know if I can obtain the camera view matrix by opencv's findhomography

    Read the article

  • maple 13 tridiagonal matrix help

    - by user292569
    i am trying to make a 100 x 100 tridiagonal matrix with 2's going down the diagonal and -1's surrounding the 2's. i can make a tridiagonal matrix with only 1's in the three diagonals and preform matrix addition to get what i want, but i want to know if there is a way to customize the three diagonals to what ever you want. maplehelp doesn't list anything useful.

    Read the article

  • How to represent double values as circles in a 2d matrix in java

    - by marco
    Hello, so I want to write a matrix explorer which enables me to reorder rows and columns of a matrix. For this porpouse I used the Jtable class. Now the problem that I have is that it is very difficult to reorder a matrix by looking at double values, so I would like to print the matrix not with the double values but with circles in which the radius of the circle represents the value. So that I can tell the difference between big values and small values quicker. Anybody has any idea how I can turn this double values into filled circles with JTable or any table class for that matter?

    Read the article

  • High speed matrix manipulation in c#?

    - by Donnie
    I'm working on some image manipulation code in c# and need to do some matrix operations (specifically 2D convolution). I have the code written in matlab which uses the conv2 function ... is there a library for C# / .NET that does good high-speed matrix manipulations? I'd be fine if it requires some specific GPU and does the matrix math on-GPU if that's what it takes.

    Read the article

  • Numpy Matrix keeps giving me an Error,

    - by uberjumper
    Okay this is werid, i keep getting the error, randomly. ValueError: matrix must be 2-dimensional So i tracked it down, and cornered it to basically something like this: a_list = [[(1,100) for _ in range(32)] for _ in range(32)] numpy.matrix(a_list) Whats wrong with this? If i print a_list it is clearly a 2d matrix of tuples, however numpy does not believe so.

    Read the article

  • How can I save and read to XML the new C++ style matrix objects in OpenCV?

    - by neuviemeporte
    The old, C style cvMat matrices could be passed to the cvSave() function for easy writing to an XML file. The new C++ style cv::Mat and cv::Mat_ matrices are not accepted by this function. The OpenCV reference has a section on XML persistence, but the three classes (FileStorage, FileNode and FileNodeIterator) lack any description or example and I can't figure out how to use them from the interface. Thanks.

    Read the article

  • C++ Matrix class hierachy

    - by bpw1621
    Should a matrix software library have a root class (e.g., MatrixBase) from which more specialized (or more constrained) matrix classes (e.g., SparseMatrix, UpperTriangluarMatrix, etc.) derive? If so, should the derived classes be derived publicly/protectively/privately? If not, should they be composed with a implementation class encapsulating common functionality and be otherwise unrelated? Something else? I was having a conversation about this with a software developer colleague (I am not per se) who mentioned that it is a common programming design mistake to derive a more restricted class from a more general one (e.g., he used the example of how it was not a good idea to derive a Circle class from an Ellipse class as similar to the matrix design issue) even when it is true that a SparseMatrix "IS A" MatrixBase. The interface presented by both the base and derived classes should be the same for basic operations; for specialized operations, a derived class would have additional functionality that might not be possible to implement for an arbitrary MatrixBase object. For example, we can compute the cholesky decomposition only for a PositiveDefiniteMatrix class object; however, multiplication by a scalar should work the same way for both the base and derived classes. Also, even if the underlying data storage implementation differs the operator()(int,int) should work as expected for any type of matrix class. I have started looking at a few open-source matrix libraries and it appears like this is kind of a mixed bag (or maybe I'm looking at a mixed bag of libraries). I am planning on helping out with a refactoring of a math library where this has been a point of contention and I'd like to have opinions (that is unless there really is an objective right answer to this question) as to what design philosophy would be best and what are the pros and cons to any reasonable approach.

    Read the article

  • building a pairwise matrix in scipy/numpy in Python from dictionaries

    - by user248237
    I have a dictionary whose keys are strings and values are numpy arrays, e.g.: data = {'a': array([1,2,3]), 'b': array([4,5,6]), 'c': array([7,8,9])} I want to compute a statistic between all pairs of values in 'data' and build an n by x matrix that stores the result. Assume that I know the order of the keys, i.e. I have a list of "labels": labels = ['a', 'b', 'c'] What's the most efficient way to compute this matrix? I can compute the statistic for all pairs like this: result = [] for elt1, elt2 in itertools.product(labels, labels): result.append(compute_statistic(data[elt1], data[elt2])) But I want result to be a n by n matrix, corresponding to "labels" by "labels". How can I record the results as this matrix? thanks.

    Read the article

  • i want to find determinant of 4x4 matrix in c#

    - by vj4u
    i want to find determinant of 4x4 matrix in c# please help urgent int ss = 4; int count = 0; int[,] matrix=new int[ss,ss]; ArrayList al = new ArrayList() {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }; for (int i = 0; i < ss; i++) { for (int j = 0; j < ss; j++) { matrix[i, j] =Convert.ToInt32( al[count]); ++count; Response.Write(matrix[i, j] + " "); } Response.Write("<br/>"); }

    Read the article

  • R - indirectly calling a matrix using a string

    - by Boris Senderovich
    Example: There is a matrix of data called VE There is a vector of string where the first element is the string VE. I need to indirectly call the string and be able to access data. For example if I need the 6th column of matrix VE then I want to do: Vector[1][,6] Essentially I need R to start reading those string as if they are the matrix names that are already in this page. I need this syntax to be dynamic because I am putting it in a loop.

    Read the article

  • Is the use of union in this matrix class completely safe?

    - by identitycrisisuk
    Unions aren't something I've used that often and after looking at a few other questions on them here it seems like there is almost always some kind of caveat where they might not work. Eg. structs possibly having unexpected padding or endian differences. Came across this in a math library I'm using though and I wondered if it is a totally safe usage. I assume that multidimensional arrays don't have any extra padding and since the type is the same for both definitions they are guaranteed to take up exactly the same amount of memory? template<typename T> class Matrix44T { ... union { T M[16]; T m[4][4]; } m; }; Are there any downsides to this setup? Would the order of definition make any difference to how this works?

    Read the article

  • Find largest rectangle containing only zeros in an N&times;N binary matrix

    - by Rajendra
    Given an NxN binary matrix (containing only 0's or 1's), how can we go about finding largest rectangle containing all 0's? Example: I 0 0 0 0 1 0 0 0 1 0 0 1 II->0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 <--IV 0 0 1 0 0 0 IV is a 6×6 binary matrix; the return value in this case will be Cell 1: (2, 1) and Cell 2: (4, 4). The resulting sub-matrix can be square or rectangular. The return value can also be the size of the largest sub-matrix of all 0's, in this example 3 × 4.

    Read the article

  • Problem with DirectX scene-graph

    - by Alex
    I'm trying to implement a basic scene graph in DirectX using C++. I am using a left child-right sibling binary tree to do this. I'm having trouble updating each node's world transformation relative to its parent (and its parent's parent etc.). I'm struggling to get it to work recursively, though I can get it to work like this: for(int i = 0; i < NUM_OBJECTS; i++) { // Initialize to identity matrix. D3DXMatrixIdentity(&mObject[i].toWorldXForm); int k = i; while( k != -1 ) { mObject[i].toWorldXForm *= mObject[k].toParentXForm; k = mObject[k].parent; } } toWorldXForm is the object's world transform and toParentXForm is the object's transform relative to the parent. I want to do this using a method within my object class (the code above is in my main class). This is what I've tried but it doesn't work (only works with nodes 1 generation away from the root) if (this->sibling != NULL) this->sibling->update(toParentXForm); D3DXMatrixIdentity(&toWorldXForm); this->toWorldXForm *= this->toParentXForm; this->toWorldXForm *= toParentXForm; toParentXForm *= this->toParentXForm; if (this->child != NULL) this->child->update(toParentXForm); Sorry if I've not been clear, please tell me if there's anything else you need to know. I've no doubt it's merely a silly mistake on my part, hopefully an outside view will be able to spot the problem.

    Read the article

  • Precision loss when transforming from cartesian to isometric

    - by Justin Skiles
    My goal is to display a tile map in isometric projection. This tile map has 25 tiles across and 25 tiles down. Each tile is 32x32. See below for how I'm accomplishing this. World Space World Space to Screen Space Rotation (45 degrees) Using a 2D rotation matrix, I use the following: double rotation = Math.PI / 4; double rotatedX = ((tileWorldX * Math.Cos(rotation)) - ((tileWorldY * Math.Sin(rotation))); double rotatedY = ((tileWorldX * Math.Sin(rotation)) + (tileWorldY * Math.Cos(rotation))); World Space to Screen Space Scale (Y-axis reduced by 50%) Here I simply scale down the Y value by a factor of 0.5. Problem And it works, kind of. There are some tiny 1px-2px gaps between some of the tiles when rendering. I think there's some precision loss somewhere, or I'm not understanding how to get these tiles to fit together perfectly. I'm not truncating or converting my values to non-decimal types until I absolutely have to (when I pass to the render method, which only takes integers). I'm not sure how to guarantee pixel perfect rendering precision when I'm rotating and scaling on a level of higher precision. Any advice? Do I need to supply for information?

    Read the article

  • How to do geometric projection shadows?

    - by John Murdoch
    I have decided that since my game world is mostly flat I don't need better shadows than geometric projections - at least for now. The only problem is I don't even know how to do those properly - that is to produce a 4x4 matrix which would render shadows for my objects (that is, I guess, project them on a horizontal XZ plane). I would like a light source at infinity (e.g., the sun at some point in the sky) and thus parallel projection. My current code does something that looks almost right for small flying objects, but actually is a very rude approximation, as it doesn't project the objects onto the ground, but simply moves them there (I think). Also it always wrongly assumes the sun is always on the zenith (projecting straight down). Gdx.gl20.glEnable(GL10.GL_BLEND); Gdx.gl20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); //shells shellTexture.bind(); shader.begin(); for (ShellState state : shellStates.values()) { transform.set(camera.combined); transform.mul(state.transform); shader.setUniformMatrix("u_worldView", transform); shader.setUniformi("u_texture", 0); shellMesh.render(shader, GL10.GL_TRIANGLES); } shader.end(); // shadows shader.begin(); for (ShellState state : shellStates.values()) { transform.set(camera.combined); m4.set(state.transform); state.transform.getTranslation(v3); m4.translate(0, -v3.y + 0.5f, 0); // TODO HACK: + 0.5f is a hack to ensure the shadow appears above the ground; this is overall a hack as we are just moving the shell to the surface instead of projecting it on the surface! transform.mul(m4); shader.setUniformMatrix("u_worldView", transform); shader.setUniformi("u_texture", 0); // TODO: make shadow black somehow shellMesh.render(shader, GL10.GL_TRIANGLES); } shader.end(); Gdx.gl.glDisable(GL10.GL_BLEND); So my questions are: a) What is the proper way to produce a Matrix4 to pass to openGL which would render the shadows for my objects? b) I am supposed to use another fragment shader for the shadows which would paint them in semi-transparent grey, correct? c) The limitation of this simplistic approach is that whenever there is some object on the ground (it is not flat) the shadows will not be drawn, correct? d) Do I need to add something very small to the y (up) coordinate to avoid z-fighting with ground textures? Or is the fact they will be semi-transparent enough to resolve that problem?

    Read the article

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