• What Do You Need Help With? V6
    7,544 replies, posted
In case you don't realise, you can totally do that in SQL, and that doesn't load everything at once: For example, if you want to know both keys and both values in case a key from CSV1 is part of a key in CSV2: [code] SELECT csv1.key as key1, csv1.value as value1, csv2.key as key2, csv2.value as value2 FROM csv1, csv2 WHERE key2 LIKE '%' || key1 || '%' [/code]
[QUOTE=proboardslol;45878105]first of all, you're using all of these variables before you declare them. It's good practice to put global variables at the top of the main method or class hierarchy. Next, you shouldn't group expressions and methods together like that; a program is a list of instructions that goes line by line. Call methods, write expressions, declare variables in the logical order instead of grouping them together to look pretty. Use comments to help you with organization. Finally, Not entirely sure I understand that goal of the program. It rolls the dice a certain amount of times, prints the random result, and THEN prints the probability that that would be the result? In all instances, the probability that you would get that result is 1/NumberOfSides. Unless you mean, what's the probability that you might get roll a 1 the first time, a 2 the second time, and a 7 the 3rd time? in which case, the probability is equally likely for any amount of configuration, whether that be (5,4,9) or (6,6,6). The formula for the probability of a set of outcomes is (1/(NumberOfSides)^NumberOfDice)) which is to be read: 1 divided by the Number of Sides to the power of the Number of dice. some pseudocode for rolling dice: [code] int main(){ int numOfSides; /*declare global variables at the top*/ int numOfDice; print("How many sides?"); getInput(numOfSides); print("How many dice?"); getInput(numOfDice); print("rolling..."); for(int i = 1; i < numOfDice; i++){ /*start at 1, since you can't roll 0 dice*/ /*if all you want is to display the output, you don't need to have declared any global variables. just use your language's print statement.*/ print(i + " " + randomNum(numOfSides)); } /*if you want to calculate the likelyhood that the printed results would appear, that likelyhood is:*/ print("probability that previous results would appear:"); print("1/"+numOfSides^numOfDice); /*will display probability in form of fraction */ } [/code] edit: also that big block of comments you put should be at the very very top of your program. the comments that have your name, date the program was created, and the description of the entire program should be before everything in the program, including before the library import statements and pre-processing[/QUOTE] Well, thank you for the feedback but what I wanted to do with the program is to ask the person how many times they want to roll and with that number, I want to calculate the percent chance of one of the 6 numbers landing on the rolls. [editline]3rd September 2014[/editline] Here's what I want the output to look like [IMG]http://puu.sh/bjX90/2dfd3742b3.png[/IMG]
[QUOTE=joshuadim;45882303]Well, thank you for the feedback but what I wanted to do with the program is to ask the person how many times they want to roll and with that number, I want to calculate the percent chance of one of the 6 numbers landing on the rolls. [editline]3rd September 2014[/editline] Here's what I want the output to look like [IMG]http://puu.sh/bjX90/2dfd3742b3.png[/IMG][/QUOTE] I'm guessing this is some sort of programming exercise. I don't quite understand it as you're explaining it, so could you post the original specification?
[QUOTE=proboardslol;45882433]I'm guessing this is some sort of programming exercise. I don't quite understand it as you're explaining it, so could you post the original specification?[/QUOTE] Basically the program asks the user for an input of how many times they want to roll 2 6-sided die and then the program calculates the probability of the combinations coming out on the x amount of rolls.
Post the original question/task, not your paraphrasing of it. Or are you just doing this as an exercise for yourself?
I made a program to find the determinant of a 3x3 matrix (to make my calculus II homework less tedious) in Java, with NetBeans 8.0. [code]package determinantfinder3x3; /** * * @author Nick */ public class DeterminantFinder3x3 { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Enter the first row's components, seperated by a space: "); Scanner sc = new Scanner(System.in); int[][] matrix = new int[3][3]; for(int i = 0; i < 3; i++) { matrix[0][i] = sc.nextInt(); } System.out.println("Enter the second row's components, seperated by a space: "); for(int i = 0; i < 3; i++) { matrix[1][i] = sc.nextInt(); } System.out.println("Enter the third row's components, seperated by a space: "); for(int i = 0; i < 3; i++) { matrix[2][i] = sc.nextInt(); } // calculate determinant int determinant = (matrix[0][0]*matrix[1][1]*matrix[2][2]) - (matrix[0][0]*matrix[1][2]*matrix[2][1]) + (matrix[0][1]*matrix[1][2]*matrix[2][0]) - (matrix[0][1]*matrix[1][0]*matrix[2][2]) + (matrix[0][2]*matrix[1][0]*matrix[2][1]) - (matrix[0][2]*matrix[1][1]*matrix[2][0]); System.out.format("Determinant of the matrix: %d%n", determinant); } } [/code] I've cleaned and built the project, but how I run the .jar file/get it to output something? It recognizes it as an executable jar file that I can double click, but nothing happens when I do so.
so i'm working on an aabb class for my physics engine, and i need it to resize when i rotate a mesh [IMG]http://gyazo.com/35f543364b057e6abe122c0731f2b019.gif[/IMG] wanununununununu [editline]4th September 2014[/editline] [IMG]http://i.gyazo.com/71f186e7bff9fb4bab595d83424e4cea.gif[/IMG] it works! it's a little big but i'd rather that than it being too small
Tis' a quickie. I want to load a huge, dynamic-sized list from a file, it [B]must[/B] to be contiguous. Should I just use a huge buffer that assumes a maximum or some creative data structure? [editline]4th September 2014[/editline] Or even better of a question, how do ya'll folks deal with loading 3d models, when it comes down to memory allocation that is.
[QUOTE=JohnnyOnFlame;45888343]Tis' a quickie. I want to load a huge, dynamic-sized list from a file, it [B]must[/B] to be contiguous. Should I just use a huge buffer that assumes a maximum or some creative data structure? [editline]4th September 2014[/editline] Or even better of a question, how do ya'll folks deal with loading 3d models, when it comes down to memory allocation that is.[/QUOTE] some formats tell you the vertex/index count in the header, but not all do. i usually just use a std::vector to load the data, then once that's done i know how many vertices there are so i can allocate a properly sized buffer. there's nothing stopping you from using a massive buffer, but it might bite you in the ass if you have a big model. what language are you coding in?
[QUOTE=MGinshe;45888687]some formats tell you the vertex/index count in the header, but not all do. i usually just use a std::vector to load the data, then once that's done i know how many vertices there are so i can allocate a properly sized buffer. there's nothing stopping you from using a massive buffer, but it might bite you in the ass if you have a big model. what language are you coding in?[/QUOTE] I'm using pure C. The std::vector would be somewhat problematic tho- since that involves realloc'ing memory and stuff, won't that cause some fragmentation?
You could just read the whole file first, and figure how big things are and then allocate the memory. If you have a truly unpredictable size you could just use realloc, it causes a little fragmentation but that's only very rarely a problem.
[QUOTE=NixNax123;45883028]I made a program to find the determinant of a 3x3 matrix (to make my calculus II homework less tedious) in Java, with NetBeans 8.0. [code]package determinantfinder3x3; /** * * @author Nick */ public class DeterminantFinder3x3 { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Enter the first row's components, seperated by a space: "); Scanner sc = new Scanner(System.in); int[][] matrix = new int[3][3]; for(int i = 0; i < 3; i++) { matrix[0][i] = sc.nextInt(); } System.out.println("Enter the second row's components, seperated by a space: "); for(int i = 0; i < 3; i++) { matrix[1][i] = sc.nextInt(); } System.out.println("Enter the third row's components, seperated by a space: "); for(int i = 0; i < 3; i++) { matrix[2][i] = sc.nextInt(); } // calculate determinant int determinant = (matrix[0][0]*matrix[1][1]*matrix[2][2]) - (matrix[0][0]*matrix[1][2]*matrix[2][1]) + (matrix[0][1]*matrix[1][2]*matrix[2][0]) - (matrix[0][1]*matrix[1][0]*matrix[2][2]) + (matrix[0][2]*matrix[1][0]*matrix[2][1]) - (matrix[0][2]*matrix[1][1]*matrix[2][0]); System.out.format("Determinant of the matrix: %d%n", determinant); } } [/code] I've cleaned and built the project, but how I run the .jar file/get it to output something? It recognizes it as an executable jar file that I can double click, but nothing happens when I do so.[/QUOTE] Anyone? This seems really trivial and I must be missing something obvious.
[QUOTE=NixNax123;45890117]Anyone? This seems really trivial and I must be missing something obvious.[/QUOTE] This might be a stupid question, but have you tried running it using "java -jar <filename.jar>" ?
I don't really know much about Java but since that program doesn't open any windows and just prints stuff to the console, you probably want to run it through the console like Cold says.
[QUOTE=BackwardSpy;45890303]I don't really know much about Java but since that program doesn't open any windows and just prints stuff to the console, you probably want to run it through the console like Cold says.[/QUOTE] So I guess I would have to make a batch file to run the jar from the console, okay! Thanks to you and Cold! I just wasn't sure if executing a .jar would automatically bring up a console or not, so I didn't know what I was doing wrong. [editline]4th September 2014[/editline] How would I make the program open a console? [editline]4th September 2014[/editline] Or even better, have a GUI where I can input the matrices and do other useful functions?
[QUOTE=NixNax123;45890520]So I guess I would have to make a batch file to run the jar from the console, okay! Thanks to you and Cold! I just wasn't sure if executing a .jar would automatically bring up a console or not, so I didn't know what I was doing wrong. [editline]4th September 2014[/editline] How would I make the program open a console? [editline]4th September 2014[/editline] Or even better, have a GUI where I can input the matrices and do other useful functions?[/QUOTE] For a console, just open a console window, cd to the directory your jar file is in and run the command that Cold posted. In terms of making a GUI, look into one of Java's multiple GUI frameworks. It has loads of thing and I don't know any of them well enough to suggest, but Swing and JavaFX seem popular.
[QUOTE=DrTaxi;45882782]Post the original question/task, not your paraphrasing of it. Or are you just doing this as an exercise for yourself?[/QUOTE] Sorry about the delay This is an exercise with nested loops because I want to learn how to use them properly Back again to my original question: How would I use nested loops for a program that asks the user for input on how many times they want to roll 2 dice and it calculates the probability of a combination happening (like rolling a 6 or a 12).
Why would you nest loops for that? You'd need several loops, sure, but they'd be one after another. Pseudocode: [code] int[10] counts; for(int i = 0; i < 10; i++) counts[i] = 0; for(int i = 0; i < numRolls; i++) { int roll = random(0,5) + random(0,5); counts[roll]++; } for(int i = 0; i < 10; i++) printf("Sum %d: %f percent", i+2, (counts[i] / numRolls) * 100); [/code] If you had the user pick the number of dice to roll every time, or the number of dice was much higher than two, it would make sense to use a nested loop to calculate the sums.
Hey, does anyone here have any experience making a networked player controller in LOVE2D? I have no idea how to approach this. I don't want to be spoonfed code, just some theory as to what I should be doing.
so i've got my aabb's working (and resizing), but now i'm having another really weird issue. i'm using a [URL="http://www.gamedev.net/page/resources/_/technical/game-programming/swept-aabb-collision-detection-and-response-r3084"]swept aabb-aabb algorithm[/URL], but my aabb's are getting stuck [i]inside[/i] eachother, rather than sliding off eachother. it's kinda hard to explain so here's a gif: [IMG]http://gyazo.com/11ec56a636de1d636a633b6b98fcb03d.gif[/IMG] here's the intersection code: [CODE] public CollisionData collidesWith(AABB other) { CollisionData collision = new CollisionData(); collision.a = this; collision.b = o; collision.colliding = false; float ixin, ixout; float iyin, iyout; float izin, izout; if(velocity.x > 0.0f) { ixin = o.extmin.x - extmax.x; ixout = o.extmax.x - extmin.x; } else { ixin = o.extmax.x - extmin.x; ixout = o.extmin.x - extmax.x; } if(velocity.y > 0.0f) { iyin = o.extmin.y - extmax.y; iyout = o.extmax.y - extmin.y; } else { iyin = o.extmax.y - extmin.y; iyout = o.extmin.y - extmax.y; } if(velocity.z > 0.0f) { izin = o.extmin.z - extmax.z; izout = o.extmax.z - extmin.z; } else { izin = o.extmax.z - extmin.z; izout = o.extmin.z - extmax.z; } float xin, xout; float yin, yout; float zin, zout; if(velocity.x == 0.0f) { xin = -9999.0f; xout = 9999.0f; } else { xin = ixin / velocity.x; xout = ixout / velocity.x; } if(velocity.y == 0.0f) { yin = -9999.0f; yout = 9999.0f; } else { yin = iyin / velocity.y; yout = iyout / velocity.y; } if(velocity.z == 0.0f) { zin = -9999.0f; zout = 9999.0f; } else { zin = izin / velocity.z; zout = izout / velocity.z; } float entry = Math.max(Math.max(xin, yin), zin); float exit = Math.min(Math.min(xout, yout), zout); if(entry > exit || xin < 0.0f && yin < 0.0f && zin < 0.0f || xin > 1.0f || yin > 1.0f || zin > 1.0f) { // no collision return collision; } else { // collsion! vec3 normal = new vec3(); if(xin > yin) { if(zin > xin) { if(izin < 0.0f) normal.z = 1.0f; else normal.z = -1.0f; } else { if(ixin < 0.0f) normal.x = 1.0f; else normal.x = -1.0f; } } else { if(zin > yin) { if(izin < 0.0f) normal.z = 1.0f; else normal.z = -1.0f; } else { if(iyin < 0.0f) normal.y = 1.0f; else normal.y = -1.0f; } } collision.colliding = true; collision.norma = normal; collision.normb = normal; collision.time = entry; return collision; } }[/CODE] and the resolution code: [CODE] public static void resolve(boolean active, Collider c, vec3 normal, float time) { if(!active) return; float remaining = 1.0f - time; float dot = (c.velocity.x * normal.x + c.velocity.y * normal.y + c.velocity.z * normal.z) * remaining; c.parent.transform.translate(c.velocity.mul(time)); c.velocity.x = dot * normal.x; c.velocity.y = dot * normal.y; c.velocity.z = dot * normal.z; } [/CODE] there are still some other problems i need to work about, but i just want to (properly) detect collision for now. also the teapot is inactive and doesn't get resolved
I didn't look through the whole code so tell me if I'm wrong. You are calculating the intersection vector then moving the offending object outward again right? Well thats the intuitive but incorrect way. Here's what you should do to get perfect collision resolving: 1. find the point in time when the two objects begin to intersect (point in time between the last and current frame) 2. When they intersect, calculate your intersection vector like you do already. 3. Move the offending object back on that lowest axis and set its velocity on that axis to zero 4. You have resolved the intersection at a point in time that was in the past. Now you need to apply the remaining movement. Do this to fix it: obj.Position += obj.Velocity * (currentFrameTime - collisionResolutionTime); So to sum it up: when you resolve an intersection / collision you must resolve only one axis (the axis on which the two objects have the lowest intersection-magnitude) and then "return". Maybe this helps? [CODE] public static void resolve(boolean active, Collider c, vec3 normal, float time) { if(!active) return; var n = Vector3.Abs(normal); // flip all negative components if(n.x < n.y && n.x < n.z) // set velocity.x to 0, move object back by "normal.x" // do this for the other two axis too // move object the remaining time from "collisionTime" to "currentFrameTime" // It should be obvious that: lastFrameTime < collisionTime <= currentFrameTime }[/CODE]
I want something like a 1d bezier curve.. that lets you focus on a point within a range of numbers for n steps. [code] start = 1 end = 10 focus = 3 steps = 25 [/code] Would result in something similar to. [code] 1 1 1 2 2 2 2 3 3 3 3 3 4 4 4 4 5 5 5 6 6 7 8 9 10 [/code] Any ideas how I would do something like this?
[QUOTE=NixNax123;45883028]I made a program to find the determinant of a 3x3 matrix (to make my calculus II homework less tedious) in Java, with NetBeans 8.0. [code]package determinantfinder3x3; /** * * @author Nick */ public class DeterminantFinder3x3 { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Enter the first row's components, seperated by a space: "); Scanner sc = new Scanner(System.in); int[][] matrix = new int[3][3]; for(int i = 0; i < 3; i++) { matrix[0][i] = sc.nextInt(); } System.out.println("Enter the second row's components, seperated by a space: "); for(int i = 0; i < 3; i++) { matrix[1][i] = sc.nextInt(); } System.out.println("Enter the third row's components, seperated by a space: "); for(int i = 0; i < 3; i++) { matrix[2][i] = sc.nextInt(); } // calculate determinant int determinant = (matrix[0][0]*matrix[1][1]*matrix[2][2]) - (matrix[0][0]*matrix[1][2]*matrix[2][1]) + (matrix[0][1]*matrix[1][2]*matrix[2][0]) - (matrix[0][1]*matrix[1][0]*matrix[2][2]) + (matrix[0][2]*matrix[1][0]*matrix[2][1]) - (matrix[0][2]*matrix[1][1]*matrix[2][0]); System.out.format("Determinant of the matrix: %d%n", determinant); } } [/code] I've cleaned and built the project, but how I run the .jar file/get it to output something? It recognizes it as an executable jar file that I can double click, but nothing happens when I do so.[/QUOTE] update: [img]http://i.imgur.com/3CsbLud.png[/img] woo! thanks guys! [editline]5th September 2014[/editline] (this is related to the matrix thing, because I calculate my cross product with determinants)
I have an assignment for Game Technology which is basically creating a mathematically correct physics simulation based on gravity without energy loss (or with energy loss, however, this is only a variable I have to change). The thing is, I have a ball and a plane. As long as the plane has no rotation other than the Y axis, the simulation works. To get additional points, I have to make it possible with arbitrary planes, meaning it should be able to bounce of any plane with any orientation. I am planning on creating a triangular shaped "bowl" that makes the ball bounce off. I don't necessarily have a problem by making the ball bounce off the plane correctly, but the requirements for this assignment are that the balls position has to be calculated using a function. The suggestion was that there would be a function called Pt (Position over time) and Vt (velocity over time). Instead of using Unity colliders to detect the collision or apply the physics, I have to calculate the time of impact myself using the ABC formula. Now I [url=http://stackoverflow.com/questions/25682990/intersect-parabola-with-rotated-plane-in-3d-engine/25690454?noredirect=1#comment40157277_25690454]asked some help on Stackoverflow[/url] but my Vector math got a bit rusty and I am not that good with planes in a 3D coordinate system anymore. The guy described how to get to the time of impact but I do not have a function that represents the orientation and position of the plane, I only have the position and rotation as Vectors (eulerAngles and position in units). [code] using UnityEngine; using System.Collections; public class BallisticMotion : MonoBehaviour { public Vector3 startPosition = new Vector3(0, 5, 0); public Vector3 gravity = new Vector3(0, -9.81f, 0); public Vector3 startVelocity = new Vector3(0, 0, 0); public float mass = 1.0f; public float dampening = 1.0f; public GameObject collidingObject; public GameObject text; private float time = 0.0f; private float lastCollision = 0.0f; private Vector3 _acceleration; private float _timeOfCollision = 0.0f; private bool _recalculateTimeOfCollision = false; float GetTimeOfCollision() { // Loop over all objects and see which one is geting the first intersection, store gameobject and time of collision float a = 0.5f * _acceleration.y; float b = startVelocity.y; float c = startPosition.y - 0.5f - (collidingObject.transform.position.y + collidingObject.transform.localScale.y / 2); float d = Mathf.Pow(b, 2) - (4.0f * a * c); if (d < 0) { Debug.LogError("d < 0, no answers"); return 0.0f; } float answer = (-b - Mathf.Sqrt(d)) / (2.0f * a); return answer; } Vector3 GetPositionForTime(float a_T) { return (0.5f * _acceleration * Mathf.Pow((a_T - lastCollision), 2)) + (startVelocity * (a_T - lastCollision)) + startPosition; } Vector3 GetVelocityForTime(float a_T) { return _acceleration * (a_T - lastCollision) + startVelocity; } void Start() { transform.position = startPosition; _acceleration = gravity * mass; _timeOfCollision = GetTimeOfCollision(); } void Update() { time += Time.deltaTime * 0.99f; transform.position = GetPositionForTime(time); if (_recalculateTimeOfCollision) { _recalculateTimeOfCollision = false; _timeOfCollision = GetTimeOfCollision(); } if (time - lastCollision > _timeOfCollision) { startPosition = GetPositionForTime(lastCollision + _timeOfCollision); startVelocity.y = -GetVelocityForTime(lastCollision + _timeOfCollision).y; lastCollision += _timeOfCollision; _recalculateTimeOfCollision = true; } text.guiText.text = "Time: " + time + "\nLast collision: " + lastCollision + "\nGet collision time: " + GetTimeOfCollision() + "\nLC + T: " + (lastCollision + GetTimeOfCollision()) + "\nStart position: " + startPosition + "\nStart velocity: " + startVelocity; } } [/code] Is there anyone here who could explain me how I could retrieve the function of my plane and what the "w" in the Stack Overflow question is?
- snip- found what i was looking for
How do I hard link and soft link txt files by default when I create them? They're spread out across three directories.
[url]http://www.gnu.org/software/libc/manual/html_node/File-System-Interface.html#File-System-Interface[/url] [url]http://msdn.microsoft.com/en-us/library/windows/desktop/aa364232(v=vs.85).aspx[/url] We need more context if you want better help, language/system etc.
[QUOTE=Cold;45917685][URL]http://www.gnu.org/software/libc/manual/html_node/File-System-Interface.html#File-System-Interface[/URL] [URL]http://msdn.microsoft.com/en-us/library/windows/desktop/aa364232(v=vs.85).aspx[/URL] We need more context if you want better help, language/system etc.[/QUOTE] [IMG]http://i.imgur.com/Zjigv7k.png[/IMG] I'm SSH-ing to my university's red hat server. We're required to use bash to make links between empty text files as part of the assignment. I understand the difference between the hard and soft links, I'm just confused by the text/how to do it.
Simply do "ln <source> <target>" to create a soft link you simply type "ln -s <source> <target>" If you want help about a command type "<command> --help", it will show you available options. If you need more linux/unix help go there instead: [url]http://facepunch.com/forumdisplay.php?f=397[/url]
This may be a bit silly, but I'm more of an arts person here. I don't know where else to post as this is the programming section, and I rather not make a whole separate thread. I'm actually looking to hire a programmer for a game I'm just drawing pixel art for. I have the general idea for it. I guess I'm the "Ideas guy with art and money." It's just a small game based on exploration. I'm looking for someone interested in taking it a bit more easy but still get things done and pitch ideas than sit there and do absolutely nothing. Again, I'm willing to pay, so hey. The engine we use can be completely up to you, though I was looking at Unreal Engine 4. The reason I say this is I'm currently working with a team of people on a huge project already, and I'd like for this to be something more of a relaxed experience. [IMG]http://puu.sh/bnuhk/b9c406d725.png[/IMG] [IMG]http://oi58.tinypic.com/nv8avo.jpg[/IMG] Eventually I'd like to move on too a larger project with the person I work with depending on how things go. Just shoot me a message on Facepunch. So as a brief overview: Willing to pay. Relaxed, but getting work done. 2D game. [B]About the game: [/B]I intend this to be a game based completely on exploration. A game where you can make a boat, go out and explore the ocean, then decide to stop with your friends and go fishing or diving for new creatures to find. Eventually, it'll lead into space travel and such. If you're interested, then I can give you a more detailed run-down but I don't want to ramble here. Thank you for your time. This is what I need help with :) [B]edit: Found someone! ^ ^[/B]
Sorry, you need to Log In to post a reply to this thread.