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...
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...
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...
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...
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...
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.
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.
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...
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...
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...
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...
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.
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...
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)...
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...
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?
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...
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?
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...
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...
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...
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...
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.
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...
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...
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...
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?
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...
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...
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?
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...
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...
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...
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...
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...
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...
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.
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.
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...
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...
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...
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
{...
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...
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...
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...
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?
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();
}...