Search Results

Search found 3165 results on 127 pages for 'triangle generation'.

Page 2/127 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Making pascal's triangle with mpz_t's

    - by SDLFunTimes
    Hey, I'm trying to convert a function I wrote to generate an array of longs that respresents Pascal's triangles into a function that returns an array of mpz_t's. However with the following code: mpz_t* make_triangle(int rows, int* count) { //compute triangle size using 1 + 2 + 3 + ... n = n(n + 1) / 2 *count = (rows * (rows + 1)) / 2; mpz_t* triangle = malloc((*count) * sizeof(mpz_t)); //fill in first two rows mpz_t one; mpz_init(one); mpz_set_si(one, 1); triangle[0] = one; triangle[1] = one; triangle[2] = one; int nums_to_fill = 1; int position = 3; int last_row_pos; int r, i; for(r = 3; r <= rows; r++) { //left most side triangle[position] = one; position++; //inner numbers mpz_t new_num; mpz_init(new_num); last_row_pos = ((r - 1) * (r - 2)) / 2; for(i = 0; i < nums_to_fill; i++) { mpz_add(new_num, triangle[last_row_pos + i], triangle[last_row_pos + i + 1]); triangle[position] = new_num; mpz_clear(new_num); position++; } nums_to_fill++; //right most side triangle[position] = one; position++; } return triangle; } I'm getting errors saying: incompatible types in assignment for all lines where a position in the triangle is being set (i.e.: triangle[position] = one;). Does anyone know what I might be doing wrong?

    Read the article

  • How to print an isosceles triangle

    - by Steve
    Hello, I'm trying to learn programming by myself, I'm working from a book that has the following problem which I can't solve: Allow the user to input two values: a character to be used for printing an isosceles triangle and the size of the peak for the triangle. For example, if the user inputs # for the character and 6 for the peak, you should produce the following display: # ## ### #### ##### ###### ##### #### ### ## # This is the code I've got so far: char character; int peak; InputValues(out character, out peak); for (int row = 1; row < peak * 2; row++) { for (int col = 1; col <= row; col++) { Console.Write(character); } Console.WriteLine(); } Console.Read() // hold console open Thanks in advance.

    Read the article

  • Drawing a textured triangle with CPU instead of GPU

    - by Jenko
    I understand the benefits of GPU rendering and such, but for a certain limited application I need to render textured triangles purely using CPU. I've built a 3D engine capable of object handling, transform, projection, culling and the likes ... now all I need is a little code snippet that draws a single textured triangle onto a bitmap... any language accepted! Inputs: Texture bitmap, Triangle U/V/W coords, Triangle X/Y screen coords Output: The textured triangle drawn at the given screen coords I've currently been using a platform function to draw triangles to screen, but I'm looking to handle it myself to speeden up the process.

    Read the article

  • Triangle Strips and Tangent Space Normal Mapping

    - by Koarl
    Short: Do triangle strips and Tangent Space Normal mapping go together? According to quite a lot of tutorials on bump mapping, it seems common practice to derive tangent space matrices in a vertex program and transform the light direction vector(s) to tangent space and then pass them on to a fragment program. However, if one was using triangle strips or index buffers, it is a given that the vertex buffer contains vertices that sit at border edges and would thus require more than one normal to derive tangent space matrices to interpolate between in fragment programs. Is there any reasonable way to not have duplicate vertices in your buffer and still use tangent space normal mapping? Which one do you think is better: Having normal and tangent encoded in the assets and just optimize the geometry handling to alleviate the cost of duplicate vertices or using triangle strips and computing normals/tangents completely at run time? Thinking about it, the more reasonable answer seems to be the first one, but why might my professor still be fussing about triangle strips when it seems so obvious?

    Read the article

  • After Effect - Triangle Wave (JavaScript)

    - by PJ Palomaki
    Hi, I'm trying to control a parameter with AE expressions and I need a triangle wave. I've got this so far: freq = 20; amplitude = 8; m = amplitude; i = time*freq; m - (i % (2*m) - m); Unfortunately this gives a saw wave (see below) and my math's a bit rusty, any takers? Thanks! PJ http://i25.photobucket.com/albums/c73/pjburnhill/Screenshot2010-04-09at153815.png

    Read the article

  • How do I draw a single Triangle with XNA and fill it with a Texture?

    - by Deukalion
    I'm trying to wrap my head around: http://msdn.microsoft.com/en-us/library/bb196409.aspx I'm trying to create a method in XNA that renders a single Triangle, then later make a method that takes a list of Triangles and renders them also. But it isn't working. I'm not understanding what all the things does and there's not enough information. My methods: // Triangle is a struct with A, B, C (didn't include) A, B, C = Vector3 public static void Render(GraphicsDevice device, List<Triangle> triangles, Texture2D texture) { foreach (Triangle triangle in triangles) { Render(device, triangle, texture); } } public static void Render(GraphicsDevice device, Triangle triangle, Texture2D texture) { BasicEffect _effect = new BasicEffect(device); _effect.Texture = texture; _effect.VertexColorEnabled = true; VertexPositionColor[] _vertices = new VertexPositionColor[3]; _vertices[0].Position = triangle.A; _vertices[1].Position = triangle.B; _vertices[2].Position = triangle.B; foreach (var pass in _effect.CurrentTechnique.Passes) { pass.Apply(); device.DrawUserIndexedPrimitives<VertexPositionColor> ( PrimitiveType.TriangleList, _vertices, 0, _vertices.Length, new int[] { 0, 1, 2 }, // example has something similiar, no idea what this is 0, 3 // 3 = gives me an error, 1 = works but no results ); } }

    Read the article

  • Android: Constructing a triangle based on Geographical information

    - by Aidan
    Hi Guys, I'm constructing a geolocation based application and I'm trying to figure out a way to make my application realise when a user is facing the direction of the given location (a particular long / lat co-ord). I've got the math figured, I just have the triangle to construct. Here's a further clarification of what I want to do.. I just want to know is there a way to get java to construct 2 other co-ordinates based on my orientation in relation to true north and my current co-ordinate? I'd like to construct a tri-angle, 45 degrees out each way of my current location (one of the points) and 1 kilometer in that direction. The problem is I don't know how to make Android/Java recognise that I want to find that point in the direction I'm currently facing.. Anyone got any ideas?

    Read the article

  • Printing a sideways triangle in java

    - by Will
    I'm trying to print a sideways triangle in java. If the user enters 5, the output should be: * *** ***** *** * If the user enters 6, the output should be: * *** ***** ***** *** * I've gotten it to work for the case when the user enters 5, 3, or 1 but my code seems to work for those three cases only. I was wondering if anyone could help me get my code working for more cases. Here it is: public void printArrow( int n ) { int asterisks = 1; for ( int i = 0; i <= n/2; i++ ) { for ( int j = i; j < asterisks; j++ ) { System.out.print( "*" ); } asterisks += 3; System.out.println(); } asterisks = asterisks / 2 - 2; for ( int i = 0; i < n/2; i++ ) { for ( int k = i; k < asterisks; k++ ) { System.out.print( "*" ); } if ( i == 1 ) { System.out.print( "*" ); } asterisks -= 2; System.out.println(); } }

    Read the article

  • Java Recursion Triangle Standing on Tip

    - by user1629075
    I was wondering how to create triangle out of asterisks on its tip rather than on its base. I have the code for making it stand on its base: public static String printTriangle (int count) { if( count <= 0 ) return ""; String p = printTriangle(count - 1); p = p + "*"; System.out.print(p); System.out.print("\n"); return p; } But then I'm stuck on how to have the greatest number of stars on the top, and then the next least, and so on. I was thinking something along the terms of having (count - p) to have the input of rows be subtracted from the amount of decrease, but then i was confused by this idea because p is string. EDIT: I tried changing the position of printTriangle(count - 1) using my original method without iterations and got 1 star per each line; how can I fix this? public class triangles { public static void main(String[] args) { printTriangle(5); } public static String printTriangle (int count) { if( count <= 0 ) return ""; String p = ""; p = p + "*"; System.out.print(p); System.out.print("\n"); p = printTriangle(count - 1); return p; } }

    Read the article

  • best way to compute vertex normals from a Triangle's list

    - by nkint
    hi i'm a complete newbie in computergraphics so sorry if it's a stupid answer. i'm trying to make a simple 3d engine from scratch, more for educational purpose than for real use. i have a Surface object with inside a Triangle's list. For now i compute normals inside Triangle class, in this way: triangle.computeFaceNormals() { Vec3D u = v1.sub(v3) Vec3D v = v1.sub(v2) Vec3D normal = Vec3D.cross(u,v) normal.normalized() this.n1 = this.n2 = this.n3 = normal } and when building surface: t = new Triangle(v1,v2,v3).computeFaceNormals() surface.addTriangle(t) and i think this is the best way to do that.. isn't it? now.. what about for vertex normals? i've found this simple algorithm: flipcode vertex normal but.. hei this algorithm has.. exponential complexity? (if my memory doesn't fail my computer science background..) (bytheway.. it has 3 nested loops.. i don't think it's the best way to do it..) any suggestion?

    Read the article

  • How to do a UITable cell with triangle indicator?

    - by zardon
    In the Linked in iphone application I noticed that they have a tableview, see the following picture with what appears to have a triangle indicator pointing upwards. Notice how the tableview cell has a little triangle pointing upwards and is part of a tableview cell. The triangle is the ---^--- part of the image. I'm wondering. How do you make a UITableView with this triangle indicator, and what is this effect called? Thanks

    Read the article

  • Triangle count for model is doubled during render

    - by zarawesome
    I am working with the Trinigy 3d engine, and it reports models to have twice as many triangles during render than it does in the model display (let's say 4000 instead of 2000). If I render the model with an additional outline shader, it reports 6000 triangles, so it's not a simple duplication. What could be the problem?

    Read the article

  • How do I draw a texture-mapped triangle in MATLAB?

    - by Petter
    I have a triangle in (u,v) coordinates in an image. I would like to draw this triangle at 3D coordinates (X,Y,Z) texture-mapped with the triangle in the image. Here, u,v,X,Y,Z are all vectors with three elements representing the three corners of the triangle. I have a very ugly, slow and unsatisfactory solution in which I (1) extract a rectangular part of the image, (2) transform it to 3D space with the transformation defined by the three points, (3) draw it with surface, and (4) finally masking out everything that is not part of the triangle with AlphaData. Surely there must be an easier way of doing this?

    Read the article

  • Implementing an automatic navigation mesh generation for 2d top down map?

    - by J2V
    I am currently in the middle of implementing an A* pathfinding for enemies. In order to implement the actual A* logic, I need a navigation mesh for my map. I am working on a 2D top down rpg map. The world is static, meaning there is no requirement for dynamic runtime mesh generation. My world objects are pixel based, not tile based and have associated data with them such as scale, rotation, origin etc. I will obviously need some vertex data being generated from my world objects, maybe create a polygon generation from color data? I could create a colormap with objects for my whole map, but I have no idea how to begin creating nav mesh polygons. How would an actual navigation mesh generation look like with this kind of available information? Can anyone maybe point to some great resources? I have looked into some 3D nav mesh tools, but they seem kind of overly complex for my situation and also have a lot of their req data available from models. Thanks a lot in advance! I have been trying to get my head around it for some time now.

    Read the article

  • Trying to Draw a 2D Triangle in OpenGL ES 2.0

    - by Nathan Campos
    I'm trying to convert a code from OpenGL to OpenGL ES 2.0 (for the BlackBerry PlayBook). So far what I got is this (just the part of the code that should draw the triangle): void setupScene() { glClearColor(250, 250, 250, 1); glViewport(0, 0, 600, 1024); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void drawScene() { setupScene(); glColorMask(0, 0, 0, 1); const GLfloat triangleVertices[] = { 100, 100, 150, 0, 200, 100 }; glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, triangleVertices); glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLES, 0, 2); } void render() { drawScene(); bbutil_swap(); } The problem is that when I launch the app instead of showing me the triangle the screen just flickers (very fast) from white to gray. Any idea what I'm doing wrong? Also, here is the entire code if you need: Full source code

    Read the article

  • Triangle - Rectangle Intersection in 2D

    - by Kevin Boyd
    I had previously asked this for 3D but now I changed my strategy and would like to do the intersection in 2D. The Rectangle is axis aligned and will always be in a fixed position, and has a constant shape and size, basically I want to clip the red areas of the triangles that extend outside the bounds of the rectangle The triangles could be in any position, shape or size, I my code I have a loop where I check the triangles one by one however I am still clueless about the math. I have identified 5 cases of triangle rectangle intersection as shown here. How do I find the intersection points of the triangle and the rectangle?

    Read the article

  • Calculate the intersection depth between a rectangle and a right triangle

    - by Celarix
    all. I'm working on a 2D platformer built in C#/XNA, and I'm having a lot of problems calculating the intersection depth between a standard rectangle (used for sprites) and a right triangle (used for sloping tiles). Ideally, the rectangle will collide with the solid edges of the triangle, and its bottom-center point will collide with the sloped edge. I've been fighting with this for a couple of days now, and I can't make sense of it. So far, the method detects intersections (somewhat), but it reports wildly wrong depths. How does one properly calculate the depth? Is there something I'm missing? Thanks!

    Read the article

  • JPA 2.1 Schema Generation (TOTD #187)

    - by arungupta
    This blog explained some of the key features of JPA 2.1 earlier. Since then Schema Generation has been added to JPA 2.1. This Tip Of The Day (TOTD) will provide more details about this new feature in JPA 2.1. Schema Generation refers to generation of database artifacts like tables, indexes, and constraints in a database schema. It may or may not involve generation of a proper database schema depending upon the credentials and authorization of the user. This helps in prototyping of your application where the required artifacts are generated either prior to application deployment or as part of EntityManagerFactory creation. This is also useful in environments that require provisioning database on demand, e.g. in a cloud. This feature will allow your JPA domain object model to be directly generated in a database. The generated schema may need to be tuned for actual production environment. This usecase is supported by allowing the schema generation to occur into DDL scripts which can then be further tuned by a DBA. The following set of properties in persistence.xml or specified during EntityManagerFactory creation controls the behaviour of schema generation. Property Name Purpose Values javax.persistence.schema-generation-action Controls action to be taken by persistence provider "none", "create", "drop-and-create", "drop" javax.persistence.schema-generation-target Controls whehter schema to be created in database, whether DDL scripts are to be created, or both "database", "scripts", "database-and-scripts" javax.persistence.ddl-create-script-target, javax.persistence.ddl-drop-script-target Controls target locations for writing of scripts. Writers are pre-configured for the persistence provider. Need to be specified only if scripts are to be generated. java.io.Writer (e.g. MyWriter.class) or URL strings javax.persistence.ddl-create-script-source, javax.persistence.ddl-drop-script-source Specifies locations from which DDL scripts are to be read. Readers are pre-configured for the persistence provider. java.io.Reader (e.g. MyReader.class) or URL strings javax.persistence.sql-load-script-source Specifies location of SQL bulk load script. java.io.Reader (e.g. MyReader.class) or URL string javax.persistence.schema-generation-connection JDBC connection to be used for schema generation javax.persistence.database-product-name, javax.persistence.database-major-version, javax.persistence.database-minor-version Needed if scripts are to be generated and no connection to target database. Values are those obtained from JDBC DatabaseMetaData. javax.persistence.create-database-schemas Whether Persistence Provider need to create schema in addition to creating database objects such as tables, sequences, constraints, etc. "true", "false" Section 11.2 in the JPA 2.1 specification defines the annotations used for schema generation process. For example, @Table, @Column, @CollectionTable, @JoinTable, @JoinColumn, are used to define the generated schema. Several layers of defaulting may be involved. For example, the table name is defaulted from entity name and entity name (which can be specified explicitly as well) is defaulted from the class name. However annotations may be used to override or customize the values. The following entity class: @Entity public class Employee {    @Id private int id;    private String name;     . . .     @ManyToOne     private Department dept; } is generated in the database with the following attributes: Maps to EMPLOYEE table in default schema "id" field is mapped to ID column as primary key "name" is mapped to NAME column with a default VARCHAR(255). The length of this field can be easily tuned using @Column. @ManyToOne is mapped to DEPT_ID foreign key column. Can be customized using JOIN_COLUMN. In addition to these properties, couple of new annotations are added to JPA 2.1: @Index - An index for the primary key is generated by default in a database. This new annotation will allow to define additional indexes, over a single or multiple columns, for a better performance. This is specified as part of @Table, @SecondaryTable, @CollectionTable, @JoinTable, and @TableGenerator. For example: @Table(indexes = {@Index(columnList="NAME"), @Index(columnList="DEPT_ID DESC")})@Entity public class Employee {    . . .} The generated table will have a default index on the primary key. In addition, two new indexes are defined on the NAME column (default ascending) and the foreign key that maps to the department in descending order. @ForeignKey - It is used to define foreign key constraint or to otherwise override or disable the persistence provider's default foreign key definition. Can be specified as part of JoinColumn(s), MapKeyJoinColumn(s), PrimaryKeyJoinColumn(s). For example: @Entity public class Employee {    @Id private int id;    private String name;    @ManyToOne    @JoinColumn(foreignKey=@ForeignKey(foreignKeyDefinition="FOREIGN KEY (MANAGER_ID) REFERENCES MANAGER"))    private Manager manager;     . . . } In this entity, the employee's manager is mapped by MANAGER_ID column in the MANAGER table. The value of foreignKeyDefinition would be a database specific string. A complete replay of Linda's talk at JavaOne 2012 can be seen here (click on CON4212_mp4_4212_001 in Media). These features will be available in GlassFish 4 promoted builds in the near future. JPA 2.1 will be delivered as part of Java EE 7. The different components in the Java EE 7 platform are tracked here. JPA 2.1 Expert Group has released Early Draft 2 of the specification. Section 9.4 and 11.2 provide all details about Schema Generation. The latest javadocs can be obtained from here. And the JPA EG would appreciate feedback.

    Read the article

  • Detect click on Triangle and Circle buttons

    - by chr1s89
    How can i detect clicks on a texture (will be a button in my game) that has a form of a triangle or circle. I know only the rectangle solution where u can use the positions + the width/height but this dont work for that because clicks will be detected at the transparent pixels. I heard of pixel-perfect collision is it the right way for this? It would be great if someone can give me a example for such a solution or other.

    Read the article

  • XNA - Detect click on triangle/circle form of a texture

    - by chr1s89
    How can i detect clicks on a texture (will be a button in my game) that has a form of a triangle or circle. I know only the rectangle solution where u can use the positions + the width/height but this dont work for that because clicks will be detected at the transparent pixels. I heard of pixel-perfect collision is it the right way for this? It would be great if someone can give me a example for such a solution or other.

    Read the article

  • How can you deflect a direction/magnitude vector based on a direction/magnitude vector and a collided triangle?

    - by JeanOTF
    So, I have a Triangle-AABB collision algorithm and I have it returning the triangle that the AABB collided with. I was hoping with the 3 vectors of the triangle and the direction/magnitude of the movement would let me determine a deflected vector so that when you run against the wall at an angle you move slower, depending on the angle of collision, but along side the wall. This would remove the sticky collision problem with only moving when there is not a collision. Any suggestions or references would be greatly appreciated! Thanks.

    Read the article

  • Foundation CSS Framework, how to change triangle on accodion [migrated]

    - by CreateSean
    I'm using foundation framework for the first time and for the most part everything is going smoothly. I am however having some trouble with the accordion in that I need to change the open/close indicator triangle that is in use. You can see it in the docs here. I've looked through the css and found the section with the accordion on foundation.css at lines 709-719 but there is no image to change or adjust. I would like to change this icon to the one in my psd, but just can't figure out where. See attached screenshot for what needs to be changed. I know how to make changes, in this case I just can't find where to make the change.

    Read the article

  • Mesh with quads to triangle mesh

    - by scape
    I want to use Blender for making models yet realize some of the polygons are not triangles but contain quads or more (example: cylinder top and bottom). I could export the the mesh as a basic mesh file and import it in to an openGL application and workout rendering the quads as tris, but anything with more than 4 vert indices is beyond me. Is it typical to convert the mesh to a triangle-based mesh inside blender before exporting it? I actually tried this through the quads_convert_to_tris method within a blender py script and the top of the cylinder does not look symmetrical. What is typically done to render a loaded mesh as a tri?

    Read the article

  • Android : glowing/pulsing line/triangle

    - by AndroidGecko
    I would like to create a simple Android app using Opengl ES 2.0 that is showing a simple shape (like line or triangle) that is glowing and pulsing like Nexus X logo in this video : http://youtu.be/jBKVAfZUFqI?t=59s What should I look for? So far I googled around for glowing effects and found techniques like "bloom" or "additive blending". Are they relevant here? how I would implement pulsing glow with them? Any links to relevant works very appreciated Thanks! P.S - I am very familiar with Android SDK; just started with OpenGL ES

    Read the article

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