2d

Difference between glOrthof and glViewPort

被刻印的时光 ゝ 提交于 2019-11-29 17:19:40
问题 On OpenGL-ES i'm confused on what the difference is between setting glOrthof() glViewPort() GLU.gluOrtho2D() with it's respective parameters. Since I believe it's all setting the part you can see to the specified coordinates (width, height). Which should I use? 回答1: The glViewport determins the portion of the window to which OpenGL is drawing to. This may be the entire window, or a subsection (think console game's "split screen" mode- a different viewport for every player). glOrthof applies

Area of self-intersecting polygon

时光毁灭记忆、已成空白 提交于 2019-11-29 17:18:54
问题 Calculating the area of a simple irregular polygon is trivial. However, consider the self-intersecting polygon ABCDEF shown at left below: If we use the linked-to formula above traversing the points in polygon order, we get an area of 0. (The 'clockwise' area cancels out the 'counter-clockwise' area.) However, if we sort the points radially around a center and calculate the area, we get the incorrect area of the polygon ABEDCF at right above. How can I best find the visible area of a self

Outline (circumference) polygon extraction from geometry constructed from equal squares

冷暖自知 提交于 2019-11-29 17:14:58
I'm sure there must exist a way to do the following but I don't know what it's called so I cannot google it. I need an algorithm to go from A to B. Does someone know what it's called or has a link to it? EDIT: Sorry I wasn't clear enough. Figure A is made up of squares and I basicly need an algoritm which removes the squares and turns it into a polygon(Figure B). The input is a plain list of axis aligned squares, the output should be a list of vertices which make up a polygon. The squares will always be aligned like on a grid, they will not overlap. To make it more clear, I want to write a

C++ Returning and Inserting a 2D array object

时光怂恿深爱的人放手 提交于 2019-11-29 15:48:17
问题 I am trying to return an array Data Member from one smaller 2D Array Object, and trying to insert the array into a larger 2D array object. But when attempting this, I came into two problems. First problem is that I want to return the name of the 2D array, but I do not know how to properly syntax to return 2D Array name. This is what my 2D Array data member looks like private: int pieceArray[4][4]; // 2D Smaller Array and I want to return this array into a function, but this one causes a

Drawing a Line - Maximum Point

白昼怎懂夜的黑 提交于 2019-11-29 13:06:01
I drew a line that is at an angle based on a slider. I am trying to make the line's end Y coordinate a certain number (let's say 300), even if it is at an angle. Any ideas on how to do this? Here is the work on my line so far: double angle = intAngle; angle = angle * Math.PI / 180; double length = 300; graphics.setColor(Color.RED); double startX = 300; double startY = 100; double endX = startX + length * Math.cos(angle); double endY = startY + length * Math.sin(angle); double end2X; double end2Y; double dblAngle; double angle2; int intAngle2; double start2X = endX; double start2Y = endY;

Passing 2D array of pointer to function C

隐身守侯 提交于 2019-11-29 12:55:18
I have a 2D array of pointer main.c Int32 * pRxSeqAddr[2][2]; func(pRxSeqAddr); / func.c void func( Int32** pRxSeqAddrPtr) { /// } I get this error: argument of type "Int32 *(*)[2]" is incompatible with parameter of type "Int32 ** I know if it was 1D array of pointer then this function call is fine, but 2D is nagging me.. please help Change func.c to: void func(Int32 *pRxSeqAddrPtr[][2]) { } In general, to pass 2D arrays to functions you need to specify the array dimensions for all but the first dimension, so in this example you need the [2] for the last dimension but you can optionally omit

2d Array in Spiral Order

匆匆过客 提交于 2019-11-29 12:00:28
I'm trying to fill an array in spiral order. So far, I can print the array in spiral order, but is there a way to modify the array so that i can fill it in spiral order and then just print the array? I'd like it to go in decreasing order like a countdown. Please help! public class Spiral { public static void main(int m, int n) { // create m by n array of integers 1 through m*n int[][] values = new int[m][n]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) values[i][j] = 1 + (m*n)*i + j; // spiral for (int i = (m*n)-1, j = 0; i > 0; i--, j++) { for (int k = j; k < i; k++) System.out

Parametric Random Function For 2D Noise Generation

风流意气都作罢 提交于 2019-11-29 11:14:19
I'm attempting to generate infinite random terrain. The terrain should generate the same every time given the same seed. I've tried using Java's Random function, creating the seed using various functions of the x and y co-ordinates of the given node on the terrain grid. Such as x*y+x+y+seed, 20*x+30*y etc. The problem with this approach is that I always see clear patterns in the numbers generated. So basically what I want is: f(x,y) = Random Number It would be helpful if the above function could include a seed of some sort, making it: f(x,y,seed) = Random Number I will need to generate several

What is the difference between System.Drawing.Point and System.Windows.Point?

旧巷老猫 提交于 2019-11-29 09:03:50
What's the difference between System.Drawing.Point and the System.Windows.Point ? In what context should which one be used? I'm working with WPF. System.Drawing.Point represents a GDI point and is used in Windows Forms. It can only hold integer values. WPF doesn't use GDI anymore, so it has its own System.Windows.Point type to represents a point, which can have non integer values. One is used with the classes in System.Drawing namespaces, and one is used with WPF. The System.Drawing.Point is not so surprisingly used with the classes in the System.Drawing namespaces. The System.Windows.Point is

Using PathIterator to return all line segments that constrain an Area?

谁说胖子不能爱 提交于 2019-11-29 08:32:56
In Java, how would one employ PathIterator to iterate through the line segments that constrain an Area ? The Area is bound only by lines (but curve support wouldn't hurt). The method should return a collection of all the line segments. Peter This works (in all situations, I believe), but it might require more thorough testing: Area area; // The value is set elsewhere in the code ArrayList<double[]> areaPoints = new ArrayList<double[]>(); ArrayList<Line2D.Double> areaSegments = new ArrayList<Line2D.Double>(); double[] coords = new double[6]; for (PathIterator pi = area.getPathIterator(null);