Search Results

Search found 1510 results on 61 pages for 'barycentric coordinates'.

Page 8/61 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Finding coordinates of a point between two points?

    - by Nicros
    Doing some 3D stuff in wpf- want to use a simpler test to see if everything is working (before moving to curves). The basic question is given two points x1,y1,z1 and x2,y2,z2 I have calculated the distance between the points. But how to find the coordinates of another point (x3,y3,z3) that lies on that line at some distance? I.e. if my line is 100 long between -50,0,0 and 50,0,0 what are the coordinates of the point at 100 * 0.1 along the line? I think this is a simple formula but I haven't found it yet....

    Read the article

  • Coordinates in distorted grid

    - by Carsten
    I have a grid in a 2D system like the one in the before image where all points A,B,C,D,A',B',C',D' are given (meaning I know the respective x- and y-coordinates). I need to calculate the x- and y-coordinates of A(new), B(new), C(new) and D(new) when the grid is distorted (so that A' is moved to A'(new), B' is moved to B'(new), C' is moved to C'(new) and D' is moved to D'(new)). The distortion happens in a way in which the lines of the grid are each divided into sub-lines of equal length (meaning for example that AB is divided into 5 parts of the equal length |AB|/5 and A(new)B(new) is divided into 5 parts of the equal length |A(new)B(new)|/5). The distortion is done with the DistortImage class of the Sandy 3D Flash engine. (My practical task is to distort an image using this class where the handles are not positioned at the corners of the image like in this demo but somewhere within it).

    Read the article

  • How do I read from a file consists of city names and coordinates/Populations and create functions to get the coordinates and population?

    - by Braybray
    I'm using Python, and I have a file which has city names and information such as names, coordinates of the city and population of the city: Youngstown, OH[4110,8065]115436 Yankton, SD[4288,9739]12011 966 Yakima, WA[4660,12051]49826 1513 2410 Worcester, MA[4227,7180]161799 2964 1520 604 Wisconsin Dells, WI[4363,8977]2521 1149 1817 481 595 How can I create a function to take the city name and return a list containing the latitude and longitude of the given city? fin = open ("miles.dat","r") def getCoordinates cities = [] for line in fin: cities.append(line.rstrip()) for word in line: print line.split() That's what I tried now; how could I get the coordinates of the city by calling the names of the city and how can I return the word of each line but not letters? Any help will be much appreciated, thanks all.

    Read the article

  • How to convert X/Y position to Canvas Left/Top properties when using ItemsControl

    - by kshahar
    I am trying to use a Canvas to display objects that have "world" location (rather than "screen" location). The canvas is defined like this: <Canvas Background="AliceBlue"> <ItemsControl Name="myItemsControl" ItemsSource="{Binding MyItems}"> <ItemsControl.ItemTemplate> <DataTemplate> <Canvas> <TextBlock Canvas.Left="{Binding WorldX}" Canvas.Top="{Binding WorldY}" Text="{Binding Text}" Width="Auto" Height="Auto" Foreground="Red" /> </Canvas> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Canvas> MyItem is defined like this: public class MyItem { public MyItem(double worldX, double worldY, string text) { WorldX = worldX; WorldY = worldY; Text = text; } public double WorldX { get; set; } public double WorldY { get; set; } public string Text { get; set; } } In addition, I have a method to convert between world and screen coordinates: Point worldToScreen(double worldX, double worldY) { // return screen coordinates using the canvas properties and an internal MapData object } With the current implementation, the items are positioned in the wrong location, because their location is not converted to screen coordinates. How can I apply the worldToScreen method on the MyItem objects before they are added to the canvas?

    Read the article

  • mouse to Three.js world coordinates during TrackballControls

    - by PanChan
    I know there are a lot of answers how to translate the mouse coordinates to the Three.js world coordinates (I prefere this one). But I have troubles on calculating when using TrackballControls. First what I expect to do: I want to add a zoom function to my scene. Not by the mouse wheel, the user should be able to draw a rectangular and by lifting the mouse button, the camera is zooming on this rectangular. I've implemented all and it works, but only when the user didn't rotate/zoom/pan with TrackballControls! If the camera was manipulated, I get wrong coordinates for my drawn rectangular. I really can't figure out why... I only know that it's an issue with TrackballControls, because without them, it works. Does anyone see my mistake? I'm sitting here for two days now and can't find it.... :( var onZoomPlaneMouseDown = function(event){ event.preventDefault(); var plane = document.getElementById("zoomPlane"); var innerPlane = document.getElementById("innerZoomPlane"); var mouseButton = event.keyCode || event.which; mouse.x = ( event.clientX / WIDTH ) * 2 - 1; mouse.y = - ( event.clientY / HEIGHT ) * 2 + 1; if(mouseButton === 1){ var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 ); projector.unprojectVector( vector, camera ); var dir = vector.sub( camera.position ).normalize(); var distance = - camera.position.z / dir.z; zoomPlaneUpperCorner = camera.position.clone().add( dir.multiplyScalar( distance ) ); innerPlane.style.display = "block"; innerPlane.style.top = event.clientY + "px"; innerPlane.style.left = event.clientX + "px"; } if(mouseButton === 3){ plane.style.display = "none"; innerPlane.style.display = "none"; } }; var onZoomPlaneMouseUp = function(event){ event.preventDefault(); var plane = document.getElementById("zoomPlane"); var innerPlane = document.getElementById("innerZoomPlane"); var mouseButton = event.keyCode || event.which; mouse.x = ( event.clientX / WIDTH ) * 2 - 1; mouse.y = - ( event.clientY / HEIGHT ) * 2 + 1; var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 ); projector.unprojectVector( vector, camera ); var dir = vector.sub( camera.position ).normalize(); var distance = - camera.position.z / dir.z; zoomPlaneLowerCorner = camera.position.clone().add( dir.multiplyScalar( distance ) ); if(mouseButton === 1){ plane.style.display = "none"; innerPlane.style.display = "none"; var center = new THREE.Vector3(); center.subVectors(zoomPlaneLowerCorner, zoomPlaneUpperCorner); center.multiplyScalar( 0.5 ); center.add(zoomPlaneUpperCorner); var rayDir = new THREE.Vector3(); rayDir.subVectors(center, camera.position ).normalize(); controls.target = center; var height = zoomPlaneUpperCorner.y - zoomPlaneLowerCorner.y; var distanceToCenter = camera.position.distanceTo(center); var minDist = (height / 2) / (Math.tan((camera.fov/2)*Math.PI/180)); camera.translateOnAxis(rayDir, (distanceToCenter - minDist)); } };

    Read the article

  • Heightmap generation

    - by Ziaix
    I want to implement something like this to create a heightmap: 'Place a group of coordinates evenly across a map, and give them height values within a certain range. Repeatedly create coordinates between all of those coordinates, setting their height by deriving a value that was a mean value of all the surrounding coordinates.' However, I'm not sure how I would go about it - I'm not sure how I could code the part where I place the coordinates in between the existing coordinates. Can anyone give any help/advice?

    Read the article

  • converting 2D mouse coordinates to 3D space in OpenGL ES

    - by Jayesh
    I want to convert mouse's current X and Y coordinates into the 3D space I have drawn in the viewport. I need to do this on the OpenGL ES platform. I found following possible solutions implemented in OpenGL, but none fits what I am looking for. I found NeHe's tutorial on doing exactly this, but in traditional OpenGL way. It uses gluUnProject. http://nehe.gamedev.net/data/articles/article.asp?article=13 Although gluUnProject is not available in OpenGL ES, its implementation seems simple enough to port back. But before calling it, we need to call glReadPixels with GL_DEPTH_COMPONENT and that is not possible in OpenGL ES. (The reason I found in this thread: http://www.khronos.org/message_boards/viewtopic.php?f=4&t=771) What I want to do is similar to picking, except that I don't want to select the object but I want exact coordinates so that I can recognize particular portion of the object that is currently under mouse cursor. I went through the Picking tutorials in this answer. http://stackoverflow.com/posts/2211312/revisions But they need glRenderMode, which I believe is absent in OpenGL ES. If you know how to solve this problem in OpenGL ES, please let me know. Thanks.

    Read the article

  • Touch coordinates in iPhone landscape mode app

    - by gok
    I am trying to make this landscape only iphone app. I only use this code for this purpose: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); } However when I click clip subviews checkbox from interface builder, the view is clipped from the middle. I also don't receive any touch events from outside of view bounds obviously. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint fingerPos = [[touches anyObject] locationInView:self.view]; NSLog(@"%f %f",fingerPos.x,fingerPos.y); } only prints for coordinates between 20 and 320 for X. But Y works fine. When i try to modify bounds by hand, everything works fine; View is positioned and shown correctly, printed coordinates are correct, I receive touch from all of the screen except between 0 and 20 for X. So Left side of the screen is unresponsive to touch events for only 20 pixels. Code I use to modify bounds: self.view.bounds = CGRectMake(-180.0f, 0.0f, 680.0f, 480.0f); What might be causing this? Weird!

    Read the article

  • Image processing: smart solution for converting superixel (128x128 pixel) coordinates needed

    - by zhengtonic
    Hi, i am searching for a smart solution for this problem: A cancer ct picture is stored inside a unsigned short array (1-dimensional). I have the location information of the cancer region inside the picture, but the coordinates (x,y) are in superpixel (128x128 unsigned short). My task is to highlight this region. I already solved this one by converting superpixel coordinates into a offset a can use for the unsigned short array. It works fine but i wonder if there is a smarter way to solve this problem, since my solution needs 3 nested for-loops. Is it possible to access the ushort array "superpixelwise", so i can navigate the ushort array in superpixels. ... // i know this does no work ... just to give you an idea what i was thinking of ... typedef struct { unsigned short[128x128] } spix; spix *spixptr; unsigned short * bufptr = img->getBuf(); spixptr = bufptr; ... best regards, zhengtonic

    Read the article

  • Calculating distance between two X,Y coordinates

    - by Umopepisdn
    I am writing a tool for a game that involves calculating the distance between two coordinates on a spherical plane 500 units across. That is, [0,0] through [499,499] are valid coordinates, and [0,0] and [499,499] are also right next to each other. Currently, in my application, I am comparing the distance between a city with an [X,Y] location respective to the user's own [X,Y] location, which they have configured in advance. To do this, I found this algorithm, which kind of works: Math.sqrt ( dx * dx + dy * dy ); Because sorting a paged list by distance is a useful thing to be able to do, I implemented this algorithm in a MySQL query and have made it available to my application using the following part of my SELECT statement: SQRT( POW( ( ".strval($sourceX)." - cityX ) , 2 ) + POW( ( ".strval($sourceY)." - cityY ) , 2 ) ) AS distance This works fine for many calculations, but does not take into account the fact that [0,0] and [499,499] are kitty-corner to one another. Is there any way I can tweak this algorithm to generate an accurate distance, given that 0 and 499 are adjacent? Thanks, -Umo

    Read the article

  • Excel: Plot order total in map coordinates

    - by Phliplip
    I have a set of data that looks like this: -X--Y----Amount- AE 24 $178,00 Y 27 $162,00 AD 34 $680,00 AK 35 $178,00 Y 25 $29,00 U 23 $178,00 X 38 $193,00 AC 30 $226,00 AK 39 $152,00 AJ 34 $217,00 AC 35 $183,00 AA 22 $211,00 Z 19 $172,00 AJ 32 $187,00 AF 26 $272,00 AI 27 $220,00 AJ 34 $320,00 AB 32 $183,00 AB 35 $272,00 AC 32 $207,00 AB 28 $178,00 AC 30 $168,00 AC 28 $178,00 AB 32 $310,00 AD 30 $188,00 AB 35 $188,00 The sample above is only an excerpt of the total dataset of 16K rows Each row represents a single delivery order, where the 2 first columns are the map coordinate and the third the purchase amount. Would it be possible to plot the above data in a chart or coordinate system. Where the each plot should be a summary of all sales in the same map coordinate. Also a similar chart of order count would be nice to have.

    Read the article

  • C# getting mouse coordinates from a tab page when selected

    - by Tom
    I wish to show the mouse coordinates only when i am viewing tabpage7. So far i have: this.tabPage7.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); protected void OnMouseMove(object sender, MouseEventArgs mouseEv) { Console.WriteLine("happening"); Console.WriteLine(mouseEv.X.ToString()); Console.WriteLine(mouseEv.Y.ToString()); } but this doesn't appear to be doing anything, could someone help show me what im doing wrong please?

    Read the article

  • Finding whether two geo-coordinates lie on the same road

    - by Amarsh
    Hi there, Given two geo-coordinates in (latitude,longitude) format, is it possible to find out if they lie on the same road? I want to do this programatically not visually. I can perhaps extract addresses and compare the street name, but since streets can change names over a long distance, this solution doesnt sem to work :( Cheers Amarsh

    Read the article

  • WPF Coordinates of intersection from two Line objects

    - by Becky Franklin
    I have two Line objects in C# WPF, and I'm trying to construct a method to work out the coordinates at which the lines intersect (if at all). After giving myself a headache reminding myself of high school maths to do this, I can't work out how to map it into programming format - anyone know how to do this? Thanks very much, Becky

    Read the article

  • Moving a unit precisely along a path in x,y coordinates

    - by Adam Eberbach
    I am playing around with a strategy game where squads move around a map. Each turn a certain amount of movement is allocated to a squad and if the squad has a destination the points are applied each turn until the destination is reached. Actual distance is used so if a squad moves one position in the x or y direction it uses one point, but moving diagonally takes ~1.4 points. The squad maintains actual position as float which is then rounded to allow drawing the position on the map. The path is described by touching the squad and dragging to the end position then lifting the pen or finger. (I'm doing this on an iPhone now but Android/Qt/Windows Mobile would work the same) As the pointer moves x, y points are recorded so that the squad gains a list of intermediate destinations on the way to the final destination. I'm finding that the destinations are not evenly spaced but can be further apart depending on the speed of the pointer movement. Following the path is important because obstacles or terrain matter in this game. I'm not trying to remake Flight Control but that's a similar mechanic. Here's what I've been doing, but it just seems too complicated (pseudocode): getDestination() { - self.nextDestination = remove_from_array(destinations) - self.gradient = delta y to destination / delta x to destination - self.angle = atan(self.gradient) - self.cosAngle = cos(self.angle) - self.sinAngle = sin(self.angle) } move() { - get movement allocation for this turn - if self.nextDestination not valid - - getNextDestination() - while(nextDestination valid) && (movement allocation remains) { - - find xStep and yStep using movement allocation and sinAngle/cosAngle calculated for current self.nextDestination - - if current position + xStep crosses the destination - - - find x movement remaining after self.nextDestination reached - - - calculate remaining direct path movement allocation (xStep remaining / cosAngle) - - - make self.position equal to self.nextDestination - - else - - - apply xStep and yStep to current position - } - round squad's float coordinates to integer screen coordinates - draw squad image on map } That's simplified of course, stuff like sign needs to be tweaked to ensure movement is in the right direction. If trig is the best way to do it then lookup tables can be used or maybe it doesn't matter on modern devices like it used to. Suggestions for a better way to do it? an update - iPhone has zero issues with trig and tracking tens of positions and tracks implemented as described above and it draws in floats anyway. The Bresenham method is more efficient, trig is more precise. If I was to use integer Bresenham I would want to multiply by ten or so to maintain a little more positional accuracy to benefit collisions/terrain detection.

    Read the article

  • Build a road network out of shapefile coordinates

    - by Sameer
    I want to build a road network from the ESRI shapefiles. I am able to read the data from the .shp files but unable to proceed any further with building the road network out of the shapefile coordinates and display it on the screen. I am not that expirienced in Java. I would appreciate any kind of suggestions on how should i proceed now.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >