Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About gonssas

  • Rank
  1. Ouch found a crazy bug for x = 0 to v.count { w(x) = w(x) + LR * R * v(x) b = b + LR * R } this is adding to the bias v.count times, hence the bias was giving crazy values.
  2. Hey, thanks for your comments. Quote: It is important to have examples that do not match the pattern. Classification is about picking which category an input belongs in. Your examples only show things that have some property P. It is also important to show things that do not have property P to allow the classifier to know what should be put in category "not P". Quote: In your case, you can try training the network to recognize things that do not match your pattern by outputting -1, just like you're training it to recognize things that do match your pattern by outputting 1. Thanks, Will try this. Is it better not to use random when generating the noisy patterns? Example of how its generating: 5% random changes (for YES) 95% random changes (for NO) Could use the other characters as NO examples, however I want to have this working for a single character first. Thanks for your comments.
  3. Note that the awnser function returns sum = b + SUM ( v(x) * w (x ) for all x ) if sum > 0 return 1 else return0 Thanks.
  4. Hey, I am working on a program that uses the perceptron algorithm to do pattern recognition and classification. Simply put I use a 2d grid in which each pixel is either on (1) or off (-1). using the following rules and algorithm taken from some reference.: w(x) = w(x) + LR * R * v(x) b = b + LR * R w - weigth vector v - value vector LR learning rate r expected result The pseudo code for the algorithm: while (1 ) { updates_made = 0 For each Example in Training Set { /* o is b + SUM( v(x) * w(x) for all x ) */ o = awnser ( Example, w, b ) if ( o != R ) { for x = 0 to v.count { w(x) = w(x) + LR * R * v(x) b = b + LR * R } updates_made = 1 } } if (updates_made==0) { break } Problem: train it to recognize a pattern. Then ask if a pattern where one of the active pixels is unactive comparting to the original pattern, it says its the same. The problem is it keeps saying its the same until all the the pixels of the original have been deleted. The sum is giving very high results and taking out one of the active pixels takes a very small value from the ottal sum. Any ideas? Thanks.
  5. gonssas

    Backface culling problem

    Quote:Original post by TheAdmiral A triangle should be culled iff 'it' faces away from the camera; iff its face normal points away from the camera iff the z component of its face normal is positive (respectively, negative) So we are required only to calculate the sign of the z component of its face normal. This can easily be extracted from the cross-product of two given edges: n = (v3 - v1) ^ (v2 - v1) n . ez = (v3.x - v1.x)(v2.y - v1.y) - (v3.y - v1.y)(v2.x - v1.x) Hey, thanks, its working now. I would like to know more about that formula. What's the 'ez'? Thanks.
  6. Hey, does anyone know where to find information about 3d solids. What I'm looking for is point coordinates and edge information of 3d objects (convex). Thanks for your comments.
  7. Hello, my program has got a rotation object but if we translate the object and then rotate, the rotation is done around the origin and around the object itself. For example here is the code that rotates around the X axis: for ( i=0; i<obj.num_points; i++ ) { temp_y = obj.points.y; temp_z = obj.points.z; obj.points.y = temp_y * cos(angle) - temp_z * sin(angle); obj.points.z = temp_y * sin(angle) + temp_z * cos(angle)); } } SO probably the code needs to translate the object back to the origin before applying the rotation and then translate it back to the point where it was. Correct? Isnt' there another way, maybe a way to change the rotation code so it works anywhere? Thanks for your comments. [Edited by - gonssas on January 15, 2007 6:39:23 PM]
  8. Fixed. Thanks for your comment.
  9. Hello, I am trying to rotate a cube but the rotation is scaling down the cube. Here is the function that rotates: void rotate_x ( Object *obj, float angle ) { int i; int j; for ( i=0; i<(*obj).num_points; i++ ) { (*obj).points.x = (*obj).points.x; (*obj).points.y = (*obj).points.y * cos(angle) - (*obj).points.z * sin(angle); (*obj).points.z = (*obj).points.y * sin(angle) + (*obj).points.z * cos(angle)); } } The value for the angle is 0.7. Thanks for your comments.
  10. gonssas

    Backface culling problem

    Quote:Original post by TheAdmiral And what's the problem? Doesnt work. Faces are not correctly taken off. Those screen shots are not up to date since I did some changes in the order of vertices. Using perspective projection. Initial value After rotation x After some other rotations x The logic is For Each Triangle X1 = Triangle[0].X / Triangle[0].Z; X2 = Triangle[1].X / Triangle[1].Z; X3 = Triangle[2].X / Triangle[2].Z; Y1 = -Triangle[0].Y / Triangle[0].Z; Y2 = -Triangle[1].Y / Triangle[1].Z; Y3 = -Triangle[2].Y / Triangle[2].Z; display = y1*(x3 - x2) + y2*(x1 - x3) + y3 *(x2 - x1); if ( display > 0 ) { /* draw */ }
  11. Hello, the backface culling code on my software renderer isn't working very well. This code is done in C using a simple library. The only library call I'm using besides start and close graphics mode is line and setcolor. Results The initial position is correct, shows only the frontal face of the cube. After a few rotations it gets lost ans starts showing all the faces again. Since it could be the order of the vertex in trhe triangle, I am looking for some info on this. The object at hand is a cube. Front face points 0...1 3...2 Back face points 4...5 7...6 So 0 = -1, 1, 1 1 = 1, 1, 1 4 = -1, 1, -1 5 = 1, 1, -1 And so on. The formula to check the sign of each triangle is display = y1*(x3 - x2) + y2*(x1 - x3) + y3 *(x2 - x1); Then the code checks if display > 0 and draws. The formula is applied after projection and translating to the center. Now the triangle ordering: 0 3 2 Initial Front Face 0 2 1 5 7 4 Initial Back Face 5 6 7 1 6 5 Initial Right Face 1 2 6 4 3 0 Initial Left Face 4 7 3 4 1 5 Initial Top Face 4 0 1 3 6 2 Initial Down Face 3 7 6 Is this ordering correct? Thanks.
  12. Hello, I am trying to code backface culling using only software rendering - No directx, no opengl. So I splitted a cube into triangles. Each face has two triangles. Calculation formula (found online) display = y1*(x3 - x2) + y2*(x1 - x3) + y3 *(x2 - x1); Some screenshots of teh results. screenshot "if display > 0" http://img305.imageshack.us/img305/6893/morethanzeroyo8.jpg screenshot "if display < 0" http://img305.imageshack.us/img305/2664/lessthanzerogj3.jpg Triangules are organized like this Face is square defined by P0, P1 P2 P3. P0---P1 | | | | P3---P2 T = P0 P2 P1 T' = P0 P3 P2 Example Front Face Triangules T = 0 1 2 T' = 0 3 2 Example Back Face Triangules T = 5 7 6 T' = 5 8 7 Where the point data is: P0 = -1, 1, 1 P1 = 1, 1, 1 P2 = 1, -1, 1 P3 = -1, -1, 1 P5 = -1, 1, -1 P6 = 1, 1, -1 P7 = 1, -1, -1 P8 = -1, -1, -1 Thanks for your comments. [Edited by - gonssas on January 10, 2007 10:51:17 AM]
  13. gonssas

    Triangle and z value

    Thanks for your comments. Will that work even after the points are projected from 3d to 2d with perspective projection? Thanks.
  14. gonssas

    Triangle and z value

    Hello, how can we know the z value (depth) of a point in a triangle? After working out a way that gives the Z over a line bewtwen two edges, my problem is now calculating the Z for a Point in the triangle but not in the edges. P0 /\ / \ Px / Pn ------ P1 That method gives Px knowing P0 and P1. So now the problem is getting Pn that is not in an edge. So read somewhere that it can get worked from a scanline / \ /--Pn-- This implicates calculating the intersection of the scanline where Pn is with the two edges of the triangle. Question 1: Is there another more direct way? Question 2: This method bust follow several calculations to get the Z. In Px case the Z is calculated from two know Z. In the Pn case the Z is calculated from two Z that are calculated from known Z. Isn't this going to give only aproximated results? thanks.
  15. Hello, The foolowing code was created to allow for objects with any number of vertex. However the last assignment isn't working. typedef struct { float x; float y; } point; typedef struct { point *point; int count; } object; int main () { object random; random.point = (point *) malloc ( 4 * sizeof ( point ) ); random.point[1].x = 10; random.point[1].y = 100; random.point[0] = {10, 100 }; } The last atribution statement doesn't compile. Parse error in { token. The other 2 work fine. Isn't there a way to assign like the last atribution? Thanks.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!