Search results

  1. twoski

    I Getting Points Inside Of A Polygon

    I have read about one approach where you draw a ray from a given point to the right then count how many times it collides with a polygon edge. If the number is odd, it's inside. If it's even, it's outside. The issue with this approach, i think, is that it wouldn't be any faster than my current...
  2. twoski

    I Getting Points Inside Of A Polygon

    Let's say we have a somewhat complex polygon shape. We know the list of 2d vectors that make up its border loop. Now let's say i want to create a list of points within this polygon. Currently i am using ray traces to create a grid of points that fall within the polygon. I'm certain there is...
  3. twoski

    I Creating a fair playing field for an odd number of players

    I'm more concerned with players being able to steal other player's resources. For example, the 2 middle guys will have a more aggressive situation since their resources are pretty close together and thus, those provinces will be high value to them. Other guys might have an easier time since...
  4. twoski

    I Creating a fair playing field for an odd number of players

    And here is a potential 10 player layout. Not sure if the resource positions are totally fair though.
  5. twoski

    I Creating a fair playing field for an odd number of players

    Well, unfortunately there's a lack of knowledge as to which player is being placed at which location. For all intents and purposes, it's considered random assignment. So we need to always account for all players and ensure they all have a fair start, which makes it difficult. After much...
  6. twoski

    I Creating a fair playing field for an odd number of players

    Hello guys, i have a unique problem to solve. Let's imagine you're playing a board game similar to Risk. The game can be played by anywhere from 2 to 22 players, and the game board will be resized accordingly based on the number of players. The board also wraps, so edge provinces connect to the...
  7. twoski

    Creating A 2D Map Generator

    Made some progress. Using bezier splines for province edges has given them a much more natural look. I need to add more bezier knots on the edges that are larger i think. Promising results so far though.
  8. twoski

    Vector projection to other vector

    Sorry that's not a great picture. A and B are 2 vectors in a 3d Space. I want to project Vector B to Vector A in a given direction, ie. Normalized Vector C.
  9. twoski

    Vector projection to other vector

    Let's say i have 2 arbitrary vectors in a 3d space. I want to project Vector A to Vector B using a specified normal. edit: better image A is green, B is red, C is red arrow. Blue is result. In this case, i want to project green vector to red vector in the red direction. This would give me...
  10. twoski

    Creating A 2D Map Generator

    Ah yes, that worked nicely. A few corner cases to work on and it'll be functional. Next thing to work on: Currently the polygons are very basic. I want to introduce some variance to their edges, with the goal being to create some more organic-looking shapes. Take, for example, this...
  11. twoski

    Creating A 2D Map Generator

    Okay, so it turns out the simplest approach was this: The center of each triangle formed by node connections becomes an anchor point for the polygons being drawn around the nodes. It works well except now i need an algorithm to sort these points in order to create a polygon which may or may...
  12. twoski

    Creating A 2D Map Generator

    The red squares are the big circles, the yellow squares represent the 8 potential connections that the big circle can have. In that example image, the leftmost province has 8 connections. The top left and bottom right province have a diagonal connection which means the top right cannot have any...
  13. twoski

    Creating A 2D Map Generator

    I'm afraid i don't see how this logic would remove the gaps. Assuming that you're using the connection center when constructing triangles... In situations where a province has no diagonal you can see the issue.
  14. twoski

    Creating A 2D Map Generator

    I'm using Unity with C# since it has built in UI stuff, and making interactive things with unity is much easier. The large circles denote provinces (ie. the center of a province) and the small circles (with their colored line) denote a connection between 2 province nodes. My first attempt at...
  15. twoski

    Creating A 2D Map Generator

    Hello, I am working on a map generator for a game called Dominions. I plan to make it open source once it's functional. Maps in this game typically wrap vertically and horizontally, so the generator must create maps that seamlessly wrap on the X and Y axis. Typically (for even player counts)...
  16. twoski

    Get vector position projected on line

    Let's say i have a set of lines (denoted in the image as connected at the blue dots) and a rectangle with maxs and mins known (denoted with orange dots). I want to project from the mins of my rectangle such that i get a point on the line below it (the green dot). Furthermore, this needs to be...
  17. twoski

    Differential Equations y" + y = tanx, solve this DE

    Okay so i solved the first 2, all that you got to do is compute some derivatives, not too bad. The third is a bit trickier though. Do i solve them one at a time, or is there some trick i need to do?
  18. twoski

    Differential Equations y" + y = tanx, solve this DE

    From my text, here is what they mean by explicit You should be familiar with the terms explicit and implicit functions from your study of calculus. A solution in which the dependent variable is expressed solely in terms of the independent variable and constants is said to be an explicit...
  19. twoski

    Differential Equations y" + y = tanx, solve this DE

    Okay so the first question is slightly different as well. The solution y = -(cos x) ln(sec x tan x) is given, all that is needed is to verify it is the explicit solution. To do this, could i derive y twice then add y" to y and show that the result is tanx?
  20. twoski

    Differential Equations y" + y = tanx, solve this DE

    Homework Statement 1. y" + y = tanx, solve this DE. 2. dP/dt = P(1 - P) where P = (c1et / 1 + c1et), verify that P is a solution to this DE. 3. Given the pair of functionsx and y, show they solve this system: dx/dt = x + 3y dy/dt = 5x+3y x = e-2t + 3e6t y = -e-2t + 5e6t The Attempt at a...
  21. twoski

    Entity Relationship Diagram Modifications

    The problem statement is exactly as posted... Quite vague and generic. We are not coding anything based on this, merely designing an ER diagram. It says we must use subclasses for the different "types" of people, ie. parents and children. So i think based on that we automatically need to have...
  22. twoski

    Entity Relationship Diagram Modifications

    Homework Statement Assume you are given the entity Person. This entity has 3 attributes: Name, Name of child, Name of parent. Now, assume you want to modify your design of ”People” database above to include additional information about types of people such as sex, and people who are parents...
  23. twoski

    Averaging Quaternions

    I have done debug prints, however the easiest way to see what was going on was by looking at the raw data in action. You can see that it's rotating joints in the wrong direction which results in the sporadic flipping of the middle girl. It only happens when an angle goes from a low number to...
  24. twoski

    Averaging Quaternions

    The main goal is to remove jitter, if the animation is slightly off then that just gives me one more talking point for when i showcase the different styles of smoothing.
  25. twoski

    Averaging Quaternions

    I am showcasing different methods of animation smoothing, I've already implemented quaternion lerping so now I'm trying to show a different method. Here is the definition: http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average The exponential moving average is easy to implement...
  26. twoski

    Averaging Quaternions

    Ok keyframes was misleading as an example, I'm using raw input from a kinect. Essentially, i have the last frame, and the current frame. Both have a rotation value. I want to calculate the exponential moving average of these values, however in order to do so i need to convert to euler i think...
  27. twoski

    Averaging Quaternions

    Hmm that looks correct, however i am trying to do an exponential moving average which is slightly different from the way they are doing it.
  28. twoski

    Averaging Quaternions

    This seems like a step in the right direction. Vector3 AvgPos(Vector3 lastPos, Vector3 pos) { Vector3 init = (emaAlpha * pos + ((1f - emaAlpha) * lastPos)); if (init == pos) { return init; } Vector3 res = init; Vector3 delta =...
  29. twoski

    Averaging Quaternions

    I think my problems are stemming from a situation like this: Angle 1: 10, 0, 0. Angle 2: 350, 0, 0. The distance between 10 and 350 is 20. This is pretty clear. However, by doing: (0.2 * Angle1 + ((0.8) * Angle2)) We get a new angle which is 282, 0, 0. This is totally wrong since it goes...
  30. twoski

    Averaging Quaternions

    I wasn't sure if this was the proper method - should i be converting my quaternions to euler angles, then averaging those? Or am i meant to just average the quaternions?
  31. twoski

    Averaging Quaternions

    I am trying to implement animation smoothing for a given set of keyframes. Some keyframes have "jitter" which i have to remove through my own algorithms. I am using the Unity game engine which has its own quaternion classes and such. I looked into it, and using an Exponential Moving Average...
  32. twoski

    Chomsky Normal Form Proof

    Homework Statement Grammar 'G' is any context-free grammar without any λ productions or unit productions. Let k be the max number of symbols on the right side of any production in P. Prove that there's an equivalent grammar in Chomsky Normal Form with no more than (k − 1)|P| + |T| production...
  33. twoski

    Regular Language Comparison

    Anyone? I think that the constraints of truncn(L) prohibit us from choosing n larger than |wv| so ignore that part of my initial post. Can i use a DFA to prove trunc is regualr?
  34. twoski

    Regular Language Comparison

    Homework Statement Let truncn(L) = {w: wv exists in L, |v| = n} Show that trunc is regular if L is regular. The Attempt at a Solution By the definition of regular languages, L is regular if we can come up with a regular expression or a DFA for it. This question confuses me because what if...
  35. twoski

    Regex for given languages with constraints

    Homework Statement Make a regex for the following languages on Σ = {a, b}: (a) {w | each 'a' in w is immediately preceded and followed by 'b'}. (b) {w | w has both 'ab' and 'ba' as sub-strings } (c) {w ∈ {a, b} |(na(w) − nb(w)) mod 3 =/= 0}. For c, the number of a's minus the number of b's...
  36. twoski

    Serializing A Type

    Someone on another forum told me that the solution to this would be using reflection, not sure exactly how it would work though. I would get the string name of a class (there is some method of doing this, not sure what it is though) and use reflection to instantiate that class using the string...
  37. twoski

    Serializing A Type

    Let's say i have a class which is not my own code. It is not serializable using the .NET serialization utilities. In order to save the pertinent data for this class i have created a serializable version of the class and have conversion methods which allow me to essentially convert the class to...
  38. twoski

    Deadlock Prevention

    This is a computer science course about operating systems, synchronization, parallelism, CPUs etc. Since there can be pseudo-deadlocks, should i attempt to trace a circle from one thread back to itself when it tries to acquire a resource? ie, Thread1 has already acquired Resource1. Thread2...
  39. twoski

    Deadlock Prevention

    I'd like to make a lot of changes to the assignment however i doubt they would take kindly to that. Given the description of the assignment, my best assumption of what they mean by "deadlock prevented" is that there were no resources available to the thread when it tries to acquire one, so it...
  40. twoski

    Deadlock Prevention

    Here it is Currently my code works but i have a feeling I'm not actually doing deadlock prevention the way they want us to. I don't even have any deadlock prevention in my code since it never gets stuck.
  41. twoski

    Deadlock Prevention

    When i say loop i mean a deadlock cycle, ie. This deadlock cycle can occur with the code i have, however since there is a monitor thread which frees resources from processes, the deadlock will be undone. If the monitor did not exist, then the deadlocks would be permanent.
  42. twoski

    Deadlock Prevention

    In this assignment, threads 'claim' resources. A resource cannot be accessed by more than 1 thread at a time. The issue is, even if a deadlock were to occur, the monitor would free a resource and break the loop. We have learned in class that there are 4 conditions that must hold in order for...
  43. twoski

    Deadlock Prevention

    Homework Statement Here is the relevant info from the assignment handout: http://pastebin.com/nfXcF88u [Broken] The Attempt at a Solution I have written the code, however i do not see how deadlocks can even be possible with this assignment. Since there is a monitor thread which...
  44. twoski

    Threading - Avoiding Thread Conflicts

    The task list is populated prior to creating the threads. Does this mean that waiting would be unnecessary? I don't want to lose marks on this assignment and my code seems to run correctly... There is no mention of wait/notify in the assignment handout and my code is thread safe, but the real...
  45. twoski

    Threading - Avoiding Thread Conflicts

    I've looked at a handful of tutorials on wait/notify and they're all pretty confusing. This code seems to get stuck after the first thread is made. public void run() { boolean processing = true; while (processing) { synchronized (tasks) { try {...
  46. twoski

    Threading - Avoiding Thread Conflicts

    Well in order for my program to be thread safe wouldn't i have to implement blocking in some way to protect the shared resource (which is the task list in this case)? Perform is a method which just checks if a static TreeSet contains an arbitrary value... I assume it was just meant to be some...
  47. twoski

    Threading - Avoiding Thread Conflicts

    Wouldn't it also depend on the computer running the code and therefore be very subjective when it comes to optimization and speed gains? I have some more snippets from the assignment handout. The teacher seems to think we can achieve close to linear speed increases, though i have no idea how...
  48. twoski

    Threading - Avoiding Thread Conflicts

    Ah, i created my own TaskList class and put the synchronized function within that class and now my program works. Part of my assignment requires me to optimize the code such that a greater number of threads will result in faster code execution. Right now if i run the program with large data...
  49. twoski

    Threading - Avoiding Thread Conflicts

    I assumed that any method that is synchronized would synchronize regardless of being in a thread or not. If i made a method external to the thread class which was synchronized and called this method from the thread class, would that work?
  50. twoski

    Threading - Avoiding Thread Conflicts

    I think i may have figured something out here. private synchronized Task GetTask() { if (!tasks.isEmpty()) { Task t = (Task) tasks.remove(); return t; } return null; } public void run() { Task t; while ((t = GetTask()) != null) { t.Perform(); }...
Top