2d

How to find the largest circle that lies within a sampled boundary?

試著忘記壹切 提交于 2019-12-01 05:38:22
Given sets of 2D points which are the boundaries of an irregular shape, a shape which may not be convex and may have internal holes, is there an algorithm to find the largest circle that fits within the boundaries? I've done a good bit of searching, and I do find algorithms that are close, such as the largest empty circle problem, but none that I have found so far match the constraints I have. Problem is not good defined since set of points don't bound any area. Boundary you mention should be some curve, probably polygon. Without that you can't say that there are internal holes, and also can't

How to find coordinates of a 2d equilateral triangle in C?

Deadly 提交于 2019-12-01 05:26:38
I have the coordinates (x,y) of 2 points. I want to build the third point so that these 3 points make an equilateral triangle. How can I calculate the third point? Thank you After reading the posts (specially vkit's) I produced this simple piece of code which will do the trick for one direction (remember that there are two points). The modification for the other case shold be trivial. #include<stdio.h> #include<math.h> typedef struct{ double x; double y; } Point; Point vertex(Point p1, Point p2){ double s60 = sin(60 * M_PI / 180.0); double c60 = cos(60 * M_PI / 180.0); Point v = { c60 * (p1.x

Graphics - equation to convert 3d point to 2d projection

房东的猫 提交于 2019-12-01 04:09:45
问题 I am a graphics novice, but am playing with HTML5 Canvas, javascript and some shapes and images. If I have a camera at point C.x,C.y,C.z, and a point at P.x,P.y,P.z, what is the easiest way to convert the point to a 2d point so I can render an image at that point with the correct scaling so my perspective is correct? I'm after the equations, not a library. Thanks! 回答1: It is called the Perspective Projection and the formula you seek is just the matrix-multiplication found here: http://en

Programmatically Reducing JPEG file size

那年仲夏 提交于 2019-12-01 04:08:35
Apologies for any ignorance, but I have never worked with jpeg images (let alone any types of images) in Java before. Supposing I want to send a jpeg image from a web service to a client. Is there any way that I can reduce the jpeg file size by manipulating the colour profile of the image in some way? I have already been able to reduce the image size by scaling it using a neat tool for BufferedImages called imgscalr . See here . I would also like a jpeg that has less colours than a high quality jpeg image. For example, I would like to be able to use 8bit colour in my jpeg instead of say 16bit

Filling up a 2D array with random numbers in javascript

故事扮演 提交于 2019-12-01 04:06:24
问题 I'm really sorry if anything like this has been posted here before but I couldn't find anything, I'm kinda new to the site still! So for a while now I've been learning a bit about game development through html5 and javascript and I stumbled upon making tileset maps, I now have a tileset and an 2D array that I want to put certain tiles in (the number varies between 6 and 10 in this case). I figured it could be a cool function to make the map choose between a small set of similar tiles so I don

How to find the largest circle that lies within a sampled boundary?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 03:13:39
问题 Given sets of 2D points which are the boundaries of an irregular shape, a shape which may not be convex and may have internal holes, is there an algorithm to find the largest circle that fits within the boundaries? I've done a good bit of searching, and I do find algorithms that are close, such as the largest empty circle problem, but none that I have found so far match the constraints I have. 回答1: Problem is not good defined since set of points don't bound any area. Boundary you mention

Animation with animationSet() in android

天大地大妈咪最大 提交于 2019-12-01 03:03:42
OK here's the problem i have an ImageView in my activity, here's what it looks in main.xml: <ImageView android:id="@+id/ic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_gravity="center_horizontal"/> I want this image to move -200(left) and then to 100(right) and then back to 0 with bouncing effect. I've implement this with my code: as = new AnimationSet(true); as.setFillEnabled(true); as.setInterpolator(new BounceInterpolator()); TranslateAnimation ta = new TranslateAnimation(-300, 100, 0, 0); ta.setDuration(2000); as

Store txt file values into 2D array

痴心易碎 提交于 2019-12-01 02:01:44
Firstly, here is my code http://pastebin.com/BxpE7aFA . Now. I want to read a text file which looks like this http://pastebin.com/d3PWqSTV and put all those integers into an array, called level. level has a size of 100x25, which is declared at the top. My only problem now is where you see the ???. How do I get the char from the file, and put that into level[i][j]? Check the code of initialization of a matrix, it should be int level[HEIGHT][WIDTH]; not int level[WIDTH][HEIGHT]; also, your data rows are shorter than WIDTH . The code works the next way: we loop through all lines of a level matrix

Determine color of a pixel in a winforms application

随声附和 提交于 2019-12-01 00:03:40
I'd like to be able to determine the backgroundcolor of a winform at a certain point on the screen, so I can take some action depending on that particular color. Sadly the System.Drawing library doesn't seem to specify a method that enables me to do so. How should I then determine the color at a certain point? Use that : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Drawing; namespace ColorUnderCursor { class CursorColor { [DllImport("gdi32")] public static extern uint GetPixel(IntPtr hDC, int XPos, int

Large scrolling background in OpenGL ES

≯℡__Kan透↙ 提交于 2019-11-30 23:54:53
I am working on a 2D scrolling game for iPhone. I have a large image background, say 480×6000 pixels, of only a part is visible (exactly one screen’s worth, 480×320 pixels). What is the best way to get such a background on the screen? Currently I have the background split into several textures (to get around the maximum texture size limit) and draw the whole background in each frame as a textured triangle strip. The scrolling is done by translating the modelview matrix. The scissor box is set to the window size, 480×320 pixels. This is not meant to be fast, I just wanted a working code before