• What Do You Need Help With? V6
    7,544 replies, posted
Was wondering how I can make my table rotate in OpenGL. I draw a table like this: [code] glPushMatrix(); glTranslatef(tableX, tableY, tableZ); glTranslatef(-0.5,0,3); drawTable(); glPopMatrix();[/code] And this is the keyboard handling method: [code]void pressKey(int key, int xx, int yy){ switch(key){ case GLUT_KEY_LEFT : deltaAngle = -0.01f; break; case GLUT_KEY_RIGHT : deltaAngle = 0.01f; break; case GLUT_KEY_UP : deltaMove = 0.5f; break; case GLUT_KEY_DOWN : deltaMove = -0.5f; break; case 'W' : tableX = 0.5; break; } }[/code] However it isn't working right. Not sure how best to do it I'm just sort copying what I did for moving the camera
[QUOTE=Jookia;44732758]I don't understand mathematics, but can't you just imagine complex numbers are 2D points?[/QUOTE] Vectors, not points, but yes.
IBO and EBO are the same in terms of OpenGL right? Because I'm accustomed to element buffer objects but all the OpenGL ES 2.0 tutorials use the term index buffer objects. It seems like DirectX calls them IBOs too?
[QUOTE=Jookia;44732758]I don't understand mathematics, but can't you just imagine complex numbers are 2D points?[/QUOTE] Most people I know visualize them that way. For addition and multiplication with real numbers they work the same way as 2D vectors. They have a special multiplication operation defined between them as well, which is not shared by vectors.
[QUOTE=WTF Nuke;44734181]IBO and EBO are the same in terms of OpenGL right? Because I'm accustomed to element buffer objects but all the OpenGL ES 2.0 tutorials use the term index buffer objects. It seems like DirectX calls them IBOs too?[/QUOTE] At least according to [URL="https://www.opengl.org/wiki/Vertex_Specification#Index_buffers"]this[/URL] page, they're one and the same.
[QUOTE=Jookia;44732758]I don't understand mathematics, but can't you just imagine complex numbers are 2D points?[/QUOTE] Their arithmetic is almost a compatible super set, so yes. (There's even the concept of the complex plane.) Multiplication doesn't quite behave as with vectors, but norms do since they are defined as [code]|z| := (z*,z)[/code] instead of [code]|x| := (x,x)[/code].
Okay, so after a eureka moment I understand -almost- everything about the Mandelbrot formula, complex numbers, the binomial theorem and arithmetics, etc. What I don't quite get yet is how [IMG]http://upload.wikimedia.org/math/d/6/4/d6421c2c225aebfa3ea419d84f89f96f.png[/IMG] translates to [code] real = (Treal * Treal) - (Timag * Timag); imag = 2.0 * Treal * Timag; [/code] I understand the real part, but how come the imaginary part is 2xy?
[QUOTE=Asgard;44735887]Okay, so after a eureka moment I understand -almost- everything about the Mandelbrot formula, complex numbers, the binomial theorem and arithmetics, etc. What I don't quite get yet is how [IMG]http://upload.wikimedia.org/math/d/6/4/d6421c2c225aebfa3ea419d84f89f96f.png[/IMG] translates to [code] real = (Treal * Treal) - (Timag * Timag); imag = 2.0 * Treal * Timag; [/code] I understand the real part, but how come the imaginary part is 2xy?[/QUOTE] If Re(x+iy) = x And Im(x+iy) = y (just to make sure I understand the question) And the question is (x+iy)^2 = ??? (i is the imaginary unit) So if we multiply that out we get x^2 + iyx + iyx - y^2 (-y^2 because i*i = -1) = x^2 + 2iyx - y^2 Then Re(x^2 + 2iyx - y^2) = -y^2 + x^2 Im(x^2 + 2iyx - y^2) = 2yx (The real part is -y^2 + x^2 and the imaginary part is 2yx) Hope that makes sense (and I hope I got the gist of your question!)
[QUOTE=Trumple;44736137]If Re(x+iy) = x And Im(x+iy) = y (just to make sure I understand the question) And the question is (x+iy)^2 = ??? (i is the imaginary unit) So if we multiply that out we get x^2 + iyx + iyx - y^2 (-y^2 because i*i = -1) = x^2 + 2iyx - y^2 Then Re(x^2 + 2iyx - y^2) = -y^2 + x^2 Im(x^2 + 2iyx - y^2) = 2yx (The real part is -y^2 + x^2 and the imaginary part is 2yx) Hope that makes sense (and I hope I got the gist of your question!)[/QUOTE] You did get what my question was, but I don't quite yet get what happens. The way you write out the multiplication makes sense, but [quote] Then Re(x^2 + 2iyx - y^2) = -y^2 + x^2 Im(x^2 + 2iyx - y^2) = 2yx [/quote] I'm not sure what's happening here.
[QUOTE=Asgard;44735887]Okay, so after a eureka moment I understand -almost- everything about the Mandelbrot formula, complex numbers, the binomial theorem and arithmetics, etc. What I don't quite get yet is how [IMG]http://upload.wikimedia.org/math/d/6/4/d6421c2c225aebfa3ea419d84f89f96f.png[/IMG] translates to [code] real = (Treal * Treal) - (Timag * Timag); imag = 2.0 * Treal * Timag; [/code] I understand the real part, but how come the imaginary part is 2xy?[/QUOTE] The formula [IMG]http://latex.codecogs.com/gif.latex?%28x+y%29%5E2%3Dx%5E2+2xy+y%5E2[/IMG] applied to a complex number a+bi, looks like this: [IMG]http://latex.codecogs.com/gif.latex?%28a+bi%29%5E2%3Da%5E2+2abi+%28bi%29%5E2[/IMG] This can be further simplified, since you know that i^2=-1: [IMG]http://latex.codecogs.com/gif.latex?a%5E2+2abi+%28bi%29%5E2%3Da%5E2+2abi-b%5E2[/IMG] By inspecting this result, it is clear that the real part which does not contain any factor i should be a^2-b^2. Likewise, the only term which does contain the factor i, namely 2abi, should be the imaginary part. The last step he performs is that he, by inspection, sees terms which has a factor i and term which do not. The terms which has the factor are terms of the imaginary part and the other are terms of the real part.
[QUOTE=ArgvCompany;44736215]The formula [IMG]http://latex.codecogs.com/gif.latex?(x+y)^2%3Dx^2+2xy+y^2[/IMG] applied to a complex number a+bi, looks like this: [IMG]http://latex.codecogs.com/gif.latex?(a+bi)^2%3Da^2+2abi+(bi)^2[/IMG] This can be further simplified, since you know that i^2=-1: [IMG]http://latex.codecogs.com/gif.latex?a^2+2abi+(bi)^2%3Da^2+2abi-b^2[/IMG] By inspecting this result, it is clear that the real part which does not contain any factor i should be a^2-b^2. Likewise, the only term which does contain the factor i, namely 2abi, should be the imaginary part. The last step he performs is that he, by inspection, sees terms which has a factor i and term which do not. The terms which has the factor are terms of the imaginary part and the other are terms of the real part.[/QUOTE] Thanks so much, you're all lovely. [editline]6th May 2014[/editline] Would this carry over to cubed, so [IMG]http://i.imgur.com/ezFtmSZ.png[/IMG] [code] real = X^3 + Y^3 imag = 3X^2Y + 3XY^2 [/code] Oh wait, so now that bi^3 is no longer a real number, it can't be part of the real part. So would that mean it's this? Real = a^3 Imag = 3(a)^2(bi) + 3(a)(bi)^2 + (bi)^3
[QUOTE=Asgard;44736225]Thanks so much, you're all lovely. [editline]6th May 2014[/editline] Would this carry over to cubed, so [IMG]http://i.imgur.com/ezFtmSZ.png[/IMG] [code] real = X^3 + Y^3 imag = 3X^2Y + 3XY^2 [/code] Oh wait, so now that bi^3 is no longer a real number, it can't be part of the real part. So would that mean it's this? Real = a^3 Imag = 3(a^2)(bi) + 3(a)(bi^2) + bi^3[/QUOTE] 3a(bi)^2 is still real.
[QUOTE=ArgvCompany;44736389]3a(bi)^2 is still real.[/QUOTE] So it'd have to be included in the real part? real = a^3 + 3(a)(bi)^2 imag = 3(a)^2(bi) + (bi)^3 ?
[QUOTE=Asgard;44736410]So it'd have to be included in the real part? real = a^3 + 3(a)(bi)^2 imag = 3(a)^2(bi) + (bi)^3 ?[/QUOTE] Almost correct. Im(a+bi) is usually defined as b by convention, not bi. So it should probably look like this: real = Re(z) = a^3 - 3(a)(b)^2 imag = Im(z) = 3(a)^2(b) - (b)^3 Generally, z=Re(z)+i*Im(z), not z=Re(z)+Im(z).
[QUOTE=Asgard;44736410]So it'd have to be included in the real part? real = a^3 + 3(a)(bi)^2 imag = 3(a)^2(bi) + (bi)^3 ?[/QUOTE] I think it may help if rather than writing: (x + y)^3 You wrote: (x + iy)^3 Then expanded. Treat i as you would any other variable, then at the end, resolve it's powers (e.g i^2 = -1, i^3 = (i^2)*i = -1i, etc. etc) The terms with a factor of i in them are imaginary, and the terms without are real, as ArgvCompany explained in more detail in his post So in this case, the result of expansion is: x^3 + 3i(x^2)y - 3x(y^2) - iy^3 Which means that Real = x^3 + 3x(y^2) (because these do not have factors of i) Imaginary = 3i(x^2)y - iy^3 (because these have factors of i) [url]http://www.wolframalpha.com/input/?i=%28x%2Biy%29%5E3[/url]
Thanks to you guys and this: [URL]http://www.dummies.com/how-to/content/how-to-expand-a-binomial-that-contains-complex-num.html[/URL] I feel like I now understand everything about this. Thanks so much. Now to move on to a new problem... [editline]6th May 2014[/editline] [t]http://i.imgur.com/RG5ZBWT.png[/t] We should get the fractal fad back on the road in WAYWO.
-snip- nevermind
Anybody have the names for the different look and feels in java? I'm implementing a menu bar with theme selections and i want classic windows as an option but I don't know the title and haven't been able to find it yet with google. [CODE]try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (themeString.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(TabTest.this); break; } } } catch (Exception e) { // If Metal is not available, you can set the GUI to another look and feel. } [/code] This is my code, where themestring is the name of the UI. "Metal", "Windows", and "Nimbus" work but I'm not sure what the others are.
[QUOTE=Bloodshot12;44740885]Anybody have the names for the different look and feels in java? I'm implementing a menu bar with theme selections and i want classic windows as an option but I don't know the title and haven't been able to find it yet with google. --code-- This is my code, where themestring is the name of the UI. "Metal", "Windows", and "Nimbus" work but I'm not sure what the others are.[/QUOTE] Have it print out info.getName() so you can see what the names are. They may be different depending on the system, I'm not sure.
So not necessarily a programming problem per se, but more an issue of building a MySQL query. I'll be the first to admit I am not that experienced at all with SQL, databases, or queries, and I know the shitty query I have currently is abysmal (and not just from it's horrid run-time). The situation is I am building a little data-mining personal project, with the following schema: [code]genres: (genre_id, genre_name) artists: (artist_id, artist_name) albums: (album_id, album_name, artist_id, genre_id) tracks: (track_id, track_name, album_id) lyrics: (lyric_id, lyric_word) lyrics_tracks: (lyric_id, track_id, count)[/code] Where the "lyrics" is a ubiquitous pool of unique words, and tracks are tied to "lyrics" through the junction table "lyrics_tracks", which also keeps track of how many times a unique word appears in the corresponding track. The idea is being able to pull all sorts of information from this, doing all sorts of analytics on the lyrics for any level (track-by-track, album-by-album, artist-by-artist, genre-by-genre). However, I don't know how to form decent queries to get this information. An example query I want is to be able to count how many times an artist uses each word, over the collection of all their tracks across all their albums, after throwing out a list of "common" words like "the" and "you". The below query is absolutely abysmal (I throw up a bit every time I look at it), but it does produce the result I want: [code]select distinct lyric_word as lyric_word1, artist_name as artist_name1, (select SUM(count) from (lyrics NATURAL JOIN tracks NATURAL JOIN lyrics_tracks NATURAL JOIN albums NATURAL JOIN artists) where artist_name = artist_name1 and lyric_word = lyric_word1 ) as count from (lyrics NATURAL JOIN tracks NATURAL JOIN lyrics_tracks NATURAL JOIN albums NATURAL JOIN artists) where (FIND_IN_SET(lyric_word,'the,we,to,and,I,of,you,to,a,in,is,this') = 0) order by count DESC[/code] But the timing is abhorrent. I am using the "myISAM" engine, because its writing was incredibly faster than "innoDB". My Java program that does a handful of URL requests (for pulling lyrics) and a bit of simple HTML parsing can, from start to finish (and so including those URL requests and string processing), pull 1 artist, 1 genre, 5 albums, 58 songs, ~1500 unique words, and ~5500 total words in just over 8 seconds. That query, using only the information that was grabbed above, takes over 70 seconds to return. Does anyone have any suggestions on a more efficient way to do this? I've tried looking, but don't really know how to phrase what I am asking, and no one I've talked to is really that experienced with SQL queries and was unable to help me.
Can you make the artists store a list of album_ids? And have the albums store a list of track_ids? And lyrics store an ID to find the lyrics_tracks? I don't know much about SQL, but I do know that searching for values in any kind of key-value container is VERY slow because it requires a linear search. Parents should know where their children are, but children don't necessarily have to know where their parents are.
[QUOTE=ECrownofFire;44743636]Can you make the artists store a list of album_ids? And have the albums store a list of track_ids? And lyrics store an ID to find the lyrics_tracks? I don't know much about SQL, but I do know that searching for values in any kind of key-value container is VERY slow because it requires a linear search. Parents should know where their children are, but children don't necessarily have to know where their parents are.[/QUOTE] As far as I know, you can't really store lists cleanly in SQL, without the use of junction tables (like the lyrics_tracks table). However, I considered something similar - specifically, I considered the lyrics being linked to tracks, albums, artists, and genres; effectively short-circuiting the tree. The only issue is filesize. Using the band I used as a reference, 1 artist has 5 albums, which together contain 58 songs, altogether containing 1500 unique words, and containing 5500 total unique word<->song pairs. If I store simply the track_id, song_id, and count on a pair, and assuming 4-byte integers for each value and a database entry is precisely the size of its components, that'd be 12 bytes per pair, or 12*5500 = 66,000 bytes = 66kB. If I store track_id, song_id, album_id, artist_id, genre_id, and count on a pair, then that'd be (4*6)=24 bytes per pair, or 122kB. It effectively doubles the size of the leaves. While not necessarily cataclysmic, I would certainly prefer some sort of compromise between filesize and time. If it comes to it, though, I will certainly resort to doing that sort of short-circuiting. 70 seconds for a query against data that took 8 seconds to scrape, parse, and commit is just absurd.
Ah, could you do something like artist_id -> album_id and simply have multiples of the same key? Also, you could try having your parsing count the words as well, eliminating the summation step in SQL.
After watching wolfires animation talk I want to learn some more about inverse kinematics, I get how the maths it works when there are just 2 bones (like arms) where the 2 bones and the line between each of their ends forms a triangle [IMG]http://www.intechopen.com/source/html/15855/media/image23.png[/IMG] But what happens when you are trying to simulate something more organic, like a rope or a tenticle, how do you calculate the values then? [IMG]http://softimage.wiki.softimage.com/xsidocs/dd0aa872.jpg[/IMG]
[QUOTE=Bloodshot12;44740885]Anybody have the names for the different look and feels in java? I'm implementing a menu bar with theme selections and i want classic windows as an option but I don't know the title and haven't been able to find it yet with google. [CODE]try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (themeString.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(TabTest.this); break; } } } catch (Exception e) { // If Metal is not available, you can set the GUI to another look and feel. } [/CODE] This is my code, where themestring is the name of the UI. "Metal", "Windows", and "Nimbus" work but I'm not sure what the others are.[/QUOTE] If you want to see the available Look and Feels that are installed, just do this (which is similar to what you're doing). [code] for (LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) { System.out.println(lookAndFeelInfo.getName() + ": " + lookAndFeelInfo.getClassName()); } [/code] This gives me: [code] Metal: javax.swing.plaf.metal.MetalLookAndFeel Nimbus: javax.swing.plaf.nimbus.NimbusLookAndFeel CDE/Motif: com.sun.java.swing.plaf.motif.MotifLookAndFeel GTK+: com.sun.java.swing.plaf.gtk.GTKLookAndFeel [/code] You can then just change to the specific Look and Feel you want by passing its respective class name. [editline]7th May 2014[/editline] The Windows Classic Look and Feel however is "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel", although it only works on Windows (obviously).
[QUOTE=Richy19;44744747]After watching wolfires animation talk I want to learn some more about inverse kinematics, I get how the maths it works when there are just 2 bones (like arms) where the 2 bones and the line between each of their ends forms a triangle -img- But what happens when you are trying to simulate something more organic, like a rope or a tenticle, how do you calculate the values then? -img-[/QUOTE] Good luck. I've spent about a year trying to find the mathematics for doing this, for creating N-bone inverse-kinematic rigs in the SFM. I've yet to find a calculable solution I both understand and can implement in SFM's implementation of Python.
[QUOTE=Richy19;44744747] But what happens when you are trying to simulate something more organic, like a rope or a tenticle, how do you calculate the values then? [IMG]http://softimage.wiki.softimage.com/xsidocs/dd0aa872.jpg[/IMG][/QUOTE] It depends on what you're trying to achieve. Do you want the tentacle's tip to be in a specific place that may be completely arbitrary at runtime, or do you just want it to be able to curl up and move in a tentacle-ish manner, perhaps in response to external stimuli? In the latter case, you don't actually need to implement inverse kinematics. You could either solve this problem by using a predefined animation when tip positioning matters, or by moving the segments of the tentacle based on their preceding joint's position and preceding segment's rotation when it doesn't matter where the tip is.
[QUOTE=Alternative Account;44747130]It depends on what you're trying to achieve. Do you want the tentacle's tip to be in a specific place that may be completely arbitrary at runtime, or do you just want it to be able to curl up and move in a tentacle-ish manner, perhaps in response to external stimuli? In the latter case, you don't actually need to implement inverse kinematics. You could either solve this problem by using a predefined animation when tip positioning matters, or by moving the segments of the tentacle based on their preceding joint's position and preceding segment's rotation when it doesn't matter where the tip is.[/QUOTE] Essentially to have the tip in a certain place, like if it was grabbing onto the floor/ceeling I guess one way of doing it is... I cant remember the name but start off with 2 joints then kind of subdivide them so like: [IMG]http://i.imgur.com/updw4vz.png[/IMG]
[QUOTE=Richy19;44744747]After watching wolfires animation talk I want to learn some more about inverse kinematics, I get how the maths it works when there are just 2 bones (like arms) where the 2 bones and the line between each of their ends forms a triangle [IMG]http://www.intechopen.com/source/html/15855/media/image23.png[/IMG] But what happens when you are trying to simulate something more organic, like a rope or a tenticle, how do you calculate the values then? [IMG]http://softimage.wiki.softimage.com/xsidocs/dd0aa872.jpg[/IMG][/QUOTE] You don't. There are too many solutions, so you have to either reduce the problem to the more easy one (with keyframes or by linking certain values to each other) or use a physics-based approach to target progressively. (Technically you can search for all solutions and select one based on some metric, but it's usually not really worth the trouble since that can still result in unnatural motion.)
[QUOTE=Tamschi;44748718]You don't. There are too many solutions, so you have to either reduce the problem to the more easy one (with keyframes or by linking certain values to each other) or use a physics-based approach to target progressively. (Technically you can search for all solutions and select one based on some metric, but it's usually not really worth the trouble since that can still result in unnatural motion.)[/QUOTE] Having thought about it, for the effect im thinking of (which would be for it to create the biggest ark possible) my solution above works. the 2 bines extended would be the full length of the "thing" and then as they create more of an angle I subdivide this to get the appropriate position for X joints
Sorry, you need to Log In to post a reply to this thread.