coordinates

find closest point to mouse position

血红的双手。 提交于 2019-12-12 01:59:34
问题 I've got a grid of sprites. Now I would like to drag an image on a grid-element. Therefore I need to know which x/y of the grid-element is the closest point to the mouse-position. All the grid-elements are stored in an array. How can I achieve that? 回答1: If all you need is the x,y of the closest grid then all you have to do is. var gridX:int = Math.floor(mouseX / NumberOfColumns); var gridY:int = Math.floor(mouseY / NumberOfRows); This will convert your mouse coordinates to your grid

Convert Long Lat wrong location when displaying

余生长醉 提交于 2019-12-12 01:48:06
问题 I have a long lat I don't know if it is in decimal or in degrees format. So I would like to ask if what in my two computation is correct or if it both wrong. I tried both computation and shows both wrong location so I guess that there's something I'm missing. Here's the raw long lat which I can't figure out if it is in degrees or decimal. LAT = 1430.4903N LONG = 12059.8999E My first computation would be like LAT = 1430.4903 / 100 = 14.304903 LONG = 12059.8999 /100 = 120.598999 while my

Calculation of Contact/Coordination number with Periodic Boundary Conditions

强颜欢笑 提交于 2019-12-12 01:39:47
问题 I have data for N atoms including the radius of each atom, the position of each atom and the box dimensions. I want to calculate the number of atoms each atom is in contact with and store the result. This is equivalent to calculating the number of atoms within a specified cutoff distance. The box has periodic boundary conditions, and hence a difficulty arises in remapping atoms such that the distance calculated between each atom is the minimum possible. Here is what I have so far: import

DirectX 11 Vertices Coordinates

依然范特西╮ 提交于 2019-12-12 01:01:36
问题 I'm working on my first C++ and DirectX 11 project where my current goal is to draw a colored triangle on the screen. This has worked well without any problems. However, there's one part that I would like to change, but I don't know how. I've tried searching for a solution but I havn't found any yet, and I guess that the reason is because I don't really know what I should search for. Currently I set up my triangles 3 vertices like this: VertexPos vertices[] = { { XMFLOAT3( 0.5f, 0.5f, 1.0f )}

iOS rotate UIImage using Quartz

孤街醉人 提交于 2019-12-12 00:32:04
问题 I have a UIView subclass with custom - (void)drawRect:(CGRect)rect I want to draw an UIImage at position 50,50 and have it rotated by 20 degrees. I tried the following code: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextRotateCTM (context, degreesToRad(20)); [image drawAtPoint:CGPointMake(50, 50)]; CGContextRestoreGState(context); It rotates the image correctly, but it is not at 50,50... How can I rotate an UIImage while maintaining the correct

how to get x and y coordinates of user tap/touch relative to window - android titanium mobile?

可紊 提交于 2019-12-11 23:54:49
问题 Can any one tell how to get x and y coordinates of user tap/touch relative to window - android titanium mobile?? I need to add a popup view close to tableviewrow when the user select a row. How to determine the x,y (top/left) positions? 回答1: you can use row.addEventListener('click',function(e){ alert('left:'+ e.x + ' top:'+ e.y); }); where row is an object of Titanium.UI.TableViewRow. For other objects (like window/view), you can use same eventlistener. But remember one thing: it gives the co

Java - Make Plot Points, Near Linear - Exactly Linear

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 20:18:24
问题 How would I go about changing points that are 'near' linear (within a threshold), actually linear? I have some code that checks if 3 points are linear to one another (give or take), and I want to replace those coordinates with new ones that are 100% inline. double distance = (x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3); double threshold = 4; if (Math.abs(distance) <= threshold) { // is Near line return true; } else return false; This is an EXTENSION of another post of mine... This is NOT a

Finding closest 90 degree angle spot

故事扮演 提交于 2019-12-11 18:25:34
问题 I've gotten pretty far but something just doesn't seem to work. A = 50.88259382849774,6.003988087177277 B = 50.88269282423443,6.0036662220954895 C = 50.882530369581545,6.003847271203995 The C coordinate is a little off from the 90 degree line (x) and this function I made should position C on the closest way to the x line. this.snapCoords = function(a, b, c){ var result = (b.x-a.x)*(c.x-b.x)+(b.y-a.y)*(c.y-b.y); var negative = false; if(result < 0){ result = result*-1; negative = true; }

How to get X,Y coordinates of an image in a JLabel

爷,独闯天下 提交于 2019-12-11 18:09:26
问题 I have an image of a map placed as the icon of a JLabel . I am using following code to get the X,Y coordinates of the location where the mouse is clicked. I have put this code in the MouseClick event of the JLabel . Point point = MouseInfo.getPointerInfo().getLocation(); double X = point.getX(); double Y = point.getY(); but the coordinates depend on the location of the JFrame form. If the form is moved the coordinates change. Is there anyway I can freeze the JFrame ? Or Is there anyway I can

How to truly crop a PDF file?

早过忘川 提交于 2019-12-11 18:05:25
问题 I am trying to extract and save a certain portion of a PDF file using specific coordinates (x,y,w,h). I am using the following code, which seems to be working okay: Function CroppedPdf(Source As Byte(), PageNumber As Integer, Rect As System.Drawing.Rectangle) As MemoryStream Dim reader As New PdfReader(Source) Dim h = reader.GetPageSize(1).Height Dim document = New iTextSharp.text.Document(New iTextSharp.text.Rectangle( Rect.Right / 300 * 72, h - (Rect.Top / 300 * 72), Rect.Left / 300 * 72, h