I was asked this during a Google Interview. We are given a string consisting of letters- F,L,R. - which is the instruction a robot follows F- goes forward by one step. L-turn left. R- turn right. String length can be upto 2500 characters. The string runs itself infinite times. We...

Ultimately, I want to implement an algorithm with the following specifications: Input: N planes in 3 dimensions (Ax + By + Cz = D given for each plane) Output: A list V of vertices, and A list E of edges (pairs from V), and A list F of faces (cycles...

I have been trying to figure this one out for some time now, I am making a program that uses a triangle as an arrow and been trying to figure out how to make an arrow with two points, meaning that that the first point would be at the midpoint...

I have many parallel line segments, for example L1(P1, P2) and L2(P3, P4). The Points have each x and y coordinates. These parallel line segments have varying angles between 0-180 degrees. How can I efficiantly find the perpendicular space between those line segments in c++? ...

http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon I visited the above link and tried to implement the formula to formulate the centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1). For instance if the co-ordinates are : (0,1),(1,0),(-1,0) and (0,-1), the resulting co-ordinates of centroid should be : 0.00 0.00 #include<stdio.h>...

I am experimenting with making partial sphere geometries using the extended options of the THREE.SphereGeometry constructor e.g. // material var dish_material = new THREE.MeshLambertMaterial( { color: 0x00ffff, side: THREE.DoubleSide, ambient: 0x00ffff, shading: THREE.FlatShading, transparent: true, opacity: 0.7, } ); var segment_material = new THREE.MeshLambertMaterial( { color: 0xffff00, side: THREE.DoubleSide, ambient:...

I have a line and point (2D). Ok, using Paul Bourke formula I can get the distance of ortogonal projection of point to the line. ( Also I can know if the solution is or not inside the segment of line. ) OK, But I'd like to know if the...

I need to draw in SVG parts of circle's circumference in different colours (please look at the picture below). Unfortunately I'm not good at SVG, so I found solution which is in my opinion very poor: I'm using describeArc() function from this post and I draw two paths - one...

I'm making an Android game and I'm having some problems with bitmap collision detection. The problem is that one of the bitmaps is a triangle and the second one is a rectangle. I don't know how to detect collision between them because now I use this code: if(policeY<((canvas.getHeight()/20)+eye.getHeight()) && (policeY+police.getHeight())>(canvas.getHeight()/20)){...

I am now scripting Illustrator by javascript. Is it possible to check a closed path is on the inside of an ellipse? (As drawn in below picture, I wish to check a red path is on the inside of an ellipse) A closed path is generally created by cubic bezier...

I'm trying to place six circles around a center circle. Eeach of them has the same diameter so it should be possible to place them around the center without space between or overlaps. I thinking to be close to the solution but there are small overlaps. I can't find an...

I am working with a serialization pipeline. I am taking a model and exporting it. I do not wish to export any model with a hole in a face. How would I detect a hole and report a error? I have access to all vertexes, edges, faces etc. Here is...

I have an Arraylist that saves all shapes. ArrayList<Shape> shapes = new ArrayList<Shape>(); The ArrayList is of type Shape and hence has ellipse, rectangle, line, point. But now I want to draw a triangle and save it into that same ArrayList. Is it possible to do this? I mean can...

OK. I have the points that comprise the borders of a polygon. I want to (a) use Sympy's geometry module to determine, from all of the possible line-segments between any pair of points, which segments do not cross the perimeter. This result will be the "edges" that are allowed to...

I have the following problem: I have a list of all the x, y coordinates of a polygon's points. I now need to sort them in such a way that I obtain the points in a clockwise order. Currently I have the 6 coordinates to draw a polygon but its...

I have islands in my game defined by an array of vertices. I would like to create a larger version of them to make a type of "shore", mainly for cosmetic purposes, while keeping the original shape intact to use for collision purposes. I have tried dilating it point by...

I want to display on the top left corner of an object drawed on a canvas. The left and top position of the delete button is equal to object.left + object.width and the top equal to object.top. After I rotate the object the left and top of the delete button...

I have a line which has points (x1,y1) and (x2,y2). I wanted to attach a Button to it, it should align with the line by rotating based on the line segment points. I need some help in calculating the rotation angle for the Button.

I have a 2D point A inside the [0,1]² square. The square is divided into 9 subsquares (of equal dimensions) http://www.noelshack.com/2015-23-1433689273-capture.png I want to know which subsquare the point A belongs to. I can do a if elseif else on the first coordinate, then inside each branch, another if else...

I am trying to rotate a square about its center in javascript. Although in this case I am using canvas to draw the square, I need to have a functional method of rotating the square for use elsewhere so just rotating the canvas is not acceptable. This is what I...

I'm creating an Android app which simulates petri nets. I'm representing place by circle and transition by square and I'm connecting those views by arc (it's just the name from petri nets for my purpose it's just a straight line) and here's the problem I'm facing, I know how to...

I'm making a little app to analyze geometry. In one part of my program, I use an algorithm that has to have a convex object as input. Luckily, all my objects are initially convex, but some are just barely so (see image). After I apply some transformations, my algorithm fails...

I have a map that has some DeadZones (Areas that cannot be reached) plotted on it. There comes a point in the flow of my application where I need to check if a line is reachable on this map. Now, my line intersection code is pretty solid, but I am...

Given a set of points (with order), I want to know if its shape is within certain types. The types are: rectangle = [(0,0),(0,1),(1,1),(1,0)] hexagon = [(0,0),(0,1),(1,2),(2,1),(2,0),(1,-1)] l_shape = [(0,0),(0,3),(1,3),(1,1),(3,1),(3,0)] concave = [(0,0),(0,3),(1,3),(1,1),(2,1),(2,3),(3,3),(3,0)] cross = [(0,0),(0,-1),(1,-1),(1,0),(2,0),(2,1),(1,1),(1,2),(0,2),(0,1),(-1,1),(-1,0)] For example, give roratated_rectangle = [(0,0),(1,1),(0,2),(-1,1)] We'll know it belongs to the rectangle above....

I'm trying to implement object stretching through the use of a selection bounding box, in 2D orthographic views of 3D space. The type of effect I'm trying to get is like when an object is surrounded with a selection marquee, and the sides and corners can be pulled to change...

I'm plotting data in matplotlib that the user can interact with via a lasso, which is internally represented as a list of vertices that make up a polygonal chain. What I would like to be able to do is to trim lassos as illustrated in this highly professional picture: Formally,...

I found this code snippet on raywenderlich.com, however the link to the explanation wasn't valid anymore. I "translated" the answer into Swift, I hope you can understand, it's actually quite easy even without knowing the language. Could anyone explain what exactly is going on here? Thanks for any help. class...

Hello I have a problem of finding pixel position after imrotate `img = imread('rice.png'); point = [100;120]; angle = 45; img_rot = imrotate(img,angle); new_point ??` ...

The code can be viewed at http://jsfiddle.net/qsr5bs6v/ Following are the lines to add a polyline L.polyline([[31.233, 121.465], [31.233499, 121.500634], [31.190172, 121.588107]], { color: '#000', smoothFactor: 10.0 }).addTo(map) As can be seen, there is an angle in the joint point of every two lines belonging to the polyline, like this, which...

So i have to draw a diamond shape. Not a Static diamond but a diamond that i will myself drag and draw. I've used General Path to do it but it is drawing a diamond that is not straight; the diamond is bend to the left and it's not being...

I'm making program where I need to plot some area which has been split up in many triangles. I have calculated strains in each node / each corner of the triangle. Now I need to plot the triangle with the strains. Now I have three ways of plotting the triangles....

Okay, I have a programming assignment, cyrus-beck algorithm. This algorithm needs normal vector that point to inside any convex polygon. Now i just in checking function, checks whether the point is inside or outside the edge. This question tell me how to calculate the normal vector, but it gives me...

If I have a DOM structure like this: <li> <a> <h2></h2> <img> <p></p> <button></button> </a> </li> And I want the image to be perfectly round, how would I achieve that? I tried using the following after looking at this article: .circle-box { width: 70%; height: 0; margin-top: 10px; padding-bottom: 70%;...

I know there are lots of example related to UIBezierPath, but I am very confused about the angles to use to draw arc, my requirement is like the image below to draw arcs. The length and angle should be calculated as per total number. Right now I have created a...

What is a good approach to extract rectangles from a boundary? I already have something working but it has some bugs and some things are handled more advanced then required so I want to start over. Here is what I want: Notice that on the right side the boundary get's...

I need to transform data from Well Known-Text to Oracle SDO_Geometry. I found the method SDO_UTIL.FROM_WKTGEOMETRY in Oracle that is perfect for my porpuses but it takes a long time and I need to transform a lot of geometries. Also, I know about the SDOAPI in Java but I didn't...

I am struggling with the following problem: I am given n points and a radius and I have to place them on a circle as symmetrical as possible. Currently, I used something like this: float theta = 360.0f / n; int i = 0; for (Word w : e.getValue()) {...

I get longitude and latitude and want to store the location with [Spatial Point] with mysql,, what's the queries and functions that can help me to insert the values .. ...

The polygon may or may not be convex. We can assume that the edges of the square align with X and Y axis. Calculating the intersection [A simple algorithm for polygon intersection]1 is an over-kill, as I only need to know whether they intersect (Yes or No)....

I am in need of an idea! I want to model the vascular network on the eye in 3D. I have made statistics on the branching behaviour in relation to vessel diameter, length etc. What I am stuck at right now is the visualization: The eye is approximated as a...

I've been trying to figure out the difference between these, and why ToEulerXYZ does not get the right rotation. Using MathGeoLib: axisX: x 0.80878228 float y -0.58810818 float z 0.00000000 float axisY: x 0.58811820 float y 0.80877501 float z 0.00000000 float axisZ: x 0.00000000 float y 0.00000000 float z 1.0000000...

I was wondering if there is a method to order intersection points in a list based on the direction of the intersected line. Here is a picture to get the idea: The red numbers are the polygon lines which exist in a List. Then I have another List with lines...

I've tried to implement an inefficient function to generate the points, normals, tex coords, and index list of a sphere. Ignoring the lines, when I draw the sphere with OpenGL I get the following output which is clearly wrong: Can anyone help me understand what's wrong with my code? public...

We have a red circle with radius 10. On this red cicle, there is 3 other circles in blue (radius 8) that are equally spaced by 120°. The point C is the middle of two blue circle and has a green circle (radius 2). I need to find the coordinate...

I have one vector of radii and second vector of hundreds of [X,Y] coordinates. For each possible coordinate-radius pair I have count all black pixels within a circle (whose center is placed in the coordinate) on an input binary image. What is the fastest way to do it? My only...

Suppose I have 3+ coplanar but not collinear points in R^4. To find the 2D plane (not hyperplane) in which they all lie, I used the following plane fit algorithm from MatlabCentral: function [n,V,p] = affine_fit(X) % Computes the plane that fits best (least square of the normal distance %...

I'm trying to figure out how to reverse RotateAxisAngle to get back rotations around these arbitrary axes (or equivalent rotations that yield same net rotation, doesn't have to be identical). Does anyone know how to do it? I'm using MathGeoLib, but I don't see an opposite way, to return back...

I want an array looking like this: [ [0,0,1,1,1,0,0], [0,1,1,1,1,1,0], [1,1,1,1,1,1,1], [1,1,1,1,1,1,1], [1,1,1,1,1,1,1], [0,1,1,1,1,1,0], [0,0,1,1,1,0,0], ] My first approach was to get the circumference var steps = 100; var coord = []; var x,y; for (var i = 0; i < steps; i++) { var phase = 2 * Math.PI...

This function is supposed to take in a point parameter which will be used to find the closest point to it that lies on the line segment object. In the example assertion code the function getClosestPoint(Point()) takes Point(10, 0) as parameters and should return Point(5,5) as the closest point to...

If i had an array of point structs defined as struct Point{ float x; float y; }; How would I rotate the points in this array by a given angle? As an example: Any help would be appreciated!...

I am trying to find the easiest way to determine a relative position of a point within a quadrilateral. The known are (see figure) the positions of points 1, 2, 3, 4 and 5 in the xy-coordinate system: x1, y1, x2, y2, x3, y3, x4, y4, x5, y5. Alsoo know...

I want to make a symbol rotate to point at the mouse. I'm using this function, but it doesn't work below the symbol's pivot. The inverse tan function has a range of 180 degrees right? So how can i get 360 degrees of movement? Would I need to add an...

Height = 600 Width = 100 I have a point (x,y) that moves and it's initialized at a random position in the beginning, I'd like to calculate it's next position with sin and cos. the next position maybe at ( if i move with 4 pixels ) x+4 y+4 or...

I want to make an animation have some circles. They will draw from small to big look like water ripple effect. Look like that How to make it with Android code? Please help me!!!...

I am using Three.js to show a number of custom geometry's in various positions and rotations. They are static and rarely change, but the user can add, delete or change the shape of each individual object. This has worked well using the code snippet below: var Mat=new THREE.MeshBasicMaterial( { color:...

Ihave some geometry datatype entries in one of my table in a Oracle database.I would need to import those data into a sql server table to then use them for something else. I am aware that I cannot do that with an ssis package.There might also be some conversion problems.Could...

I am building a stored procedure for SQL Server 2014. All works as expected except I receive an error when trying to use a geometry type to base the location results upon. USE UKStreetsAndPlaces GO DECLARE @Latitude Decimal(9,6) = 51.3083162 DECLARE @Longitude Decimal(9,6) = -0.7799193 DECLARE @LongitudeOperator AS NVARCHAR(1) DECLARE...

Given a plane(in my case a triangle) normal N_T and a reference Normal N_R, both have the length 1. I calculated the rotation_normal N = N_T x N_R and now i need to calculate the angle around this rotation_normal, which i get with the following calculation: angle = acos(<N_T, N_R>),...

I thought I'd use the Point2D class for calculating e. g. the angle betwen 2 points instead of creating a utility method. It turned out, it's not usable at all. Code example: Point2D p1; Point2D p2; p1 = new Point2D(0, 0); p2 = new Point2D(10, 10); System.out.println( "Point2D: " +...

I have a three-dimensional point set. Each point holds its own coordinates (x,y,z) with double values. Now I want to convert all coordinates from the point set into integer values. For example if my set consists of random points between the range 0.0 and 1.0. If I use floor() to...

Let say we have linear exp y=ax+b. Supposed we have: y1=0.5 x and y2=1.5 x. I can conclude easily that y2 has higher slope than y1 since a2=1.5 >a1=0.5. Now let consider the case of negative slope. If i have y3=-2x and y4=-0.5x. Is it correct if I say y4...

Based on the x and y coordinates, I need to implement a function like int getArea(double xcoord, double ycoord , double radius) to get the rough time on the clock. Rough Time means the time on the clock in full hours. So in this case 1 o'clock, 2 o'clock, etc......

I was doing a practice question and it was something like this,We are given N pair of coordinates (x,y) and we are given a central point too which is (x0,y0).We were asked to find maximum number of points lying on a line passing from (x0,y0). My approach:- I tried to...

I want to calculate the radius of an inverted circle. I managed to implement everything but, after hours of struggle, I could not find a formula to calculate the correct inverted radius. More info about circle inversion: http://en.wikipedia.org/wiki/Inversive_geometry https://www.youtube.com/watch?v=sG_6nlMZ8f4 My code so far: http://codepen.io/rafaelcastrocouto/pen/Mwjdga It seems to be working but...

I would like to declare a regular polygon, in this case a square without duplicated points. The problem is that the following statement returns 5, but one would expect 4. SELECT ST_NPoints(ST_GeomFromText('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')); But without the last point I get an error...

I am attempting to create a shape like the following: For the curves of the spiral, I am utilizing Quadratic Bezier Segments. PathGeometry pg1 = new PathGeometry(); PathFigure pf1 = new PathFigure() { StartPoint = new Point(Convert.ToDouble(middle) + 500, Convert.ToDouble(middle) + 500) }; PathSegmentCollection psc1= new PathSegmentCollection(); QuadraticBezierSegment arcs1 =...

I have a convex polyhedron. And I have a point inside this polyhedron. I'm trying to figure out an algorithm to find the distance to the closest face of this polyhedron. How can I do that? I know that once I have the actual faces of the polyhedron, I can...

If I had the following figure shown below and I wanted to scale the top rectangle by some factor such that the left side will still touch the circle like it does now, how would I go about doing that? This is being done in C++ where the rectangles are...

I'm currently working on a program which enables user to draw various geometric shapes. However, I got some issues on calculating and placing the angle objects onto my Canvas panel accurately. The angle object is basically an extension of the Arc2D object, which provides a additional method called computeStartAndExtent(). Inside...

I am given a polyhedron which is represented by a list of planes. The volume delimited by these planes is the actual polyhedron. I have a list of triangles, and I need to remove all the triangles that intersect or is contained in this polyhedron. My idea is to check...

I have a vector V starting at x,y with velocity dirx,diry (for example 2,3). I want to know the cooridinates of the end point of the vector if its length (i guess the norm) was equal to 40 for example. Sorry, my math knowledge it quite low, many thanks in...

I am built some Cubes with the triangle approach (24 verticies per cube). Now I want to transform this cube to a sphere (maybe, I only want to have round corners) (later, I want to animate this transformation). How can I realize this? Can I use texture coordinates or normals...

I am trying to find the tangent lines from a given point outside a closed curve (not on the curve). The curve is defined as 2D x and y coordinates of points，shaped like an irregular ellipse for example. If given a point by the user: (x0,y0) = (-30,80), how can...

I am trying to expand a circle from Zero radius to a predefined radius at the centre of the screen. The code is as follows In viewDidLoad:- - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [super viewDidLoad]; circleRadius = 0.0f;...

I am trying to make a coil with several small loops. I have a custom function to create a single helix for each loop, and at first I was calling that within a for loop several hundred times, but it was taking too long to render and slowed down the...

This question already has an answer here: Make CSS3 triangle with linear gradient 4 answers How is it possible to make a CSS arrow as a gradient instead os a solid colour? Here is my CSS" .breadcrumbDivider .arrow-right { width: 0; height: 0; border-top: 25px solid transparent; border-bottom: 25px...

I'm coding on a specialized motion controller hardware which uses a subset of Visual Basic language as its programming language. I need to make some calculations on given points, like getting center coordinates of an arc that is passing through 3 distinct points; shifting lines, getting intersection coordinates of 2...

For an ellipsoid of the form with orientation vector and centre at point , how to find whether a point is inside the ellipsoid or not? An additional note that the geometry actually is with a=b (spheroid) and therefore one axis is sufficient to define orientation Note: I see a...

I think the image says all. I have to find out the theta for any given line programatically with c#. Point X = new Point(x1,y1); Point Y = new Point(x2,y2); Now I want to draw a line from X point with theta angle. how can I implement with c#....

I have 3D points and I need to make an 2D orthographic projection of them onto a plane that is defined by the origin and a normal n. The meaning of this is basically looking at the points from the top (given the vertical vector). How can I do it?...

Looking for a code example of how to calculate (accurately) the dimensions of a rectangle from a top down view (90 degrees) at a particular angle. e.g. I have a rectangle of 1200mm x 2000mm How would i determine the new perspective measurements of the rectangle if it was angled...

What does MATLAB's estimateUncalibratedRectification do in mathematical/geometrical terms ? What does it calculate exactly ? As far as I understand, if the camera parameters are unknown then only the fundamental matrix can be computed from two images, not the essential matrix. So, as far as I understand, estimateUncalibratedRectification's result should...

What is the depth-buffer content in OpenGL related to? Are they the Z-values or the actual depth values from the eye (i.e sqrt(X2+Y2+Z2))?

I have a single Geometry Field in a table select g3e_GEOMETRY from MyTable where g3e_FID = 15463352 This returns (3001, , (, , ), (1, 1, 1, 4, 1, 0, , , , , , , , , , , , , , , , , , , , ,...

I have a function dependent on phi and theta, which I want to plot on the surface of a sphere. The date is stored in a .txt file with the columns: 1: x = R*sin(theta)*cos(phi) 2: y = R*sin(theta)*sin(phi) 3: z = R*cos(theta) 4: density I use the following gnuplot...

I'm currently working with files that define rectangular shapes in a way that I'm unfamiliar with. Someone told me it might be a matrix, but knowing that doesn't particularly help me with my problem, converting it to points and back. For example, I have these values: 0.95, -0.28, -0.28, -0.95,...

I am recreating this gauge in QT, and having trouble with the colored bands part. I want to be able to color the bands from any place on the gauge (Ex from 20 to 50). The math is confusing, should I use a drawarc function? The gauge circle diameter is...

I have a single large rectangle of dimensions L*W, and n smaller rectangles that each have the same dimension l * w. Every small rectangle has the same dimensions. My goal is to fit all n of smaller rectangles into the large rectangle while making the most efficient use of...

I've got a side bar which contains a list, however I want a triangle located at the right side of the div. Now I know about the border trick, but then the text isn't located at the same location where it should be. JSFiddle: http://jsfiddle.net/ppX53/44/ This is how my code...

I have two lines specified by two points with x and y coordinate each. The first point (where the lines begin) is equal meaning that I have 3 points A, B and C where one line is from A to B and the other one from A to C. I...

C++, I want calculate the angle of the direction of the two points. Here is a picture which shows the two points and the direction of how to get the angle of the direction? p1 - start point. p2 - direction point. me need direction angle(facing?) from p1 to p2...

The shown image below got province lines, this is at a zoom of 7. However; if I zoom out to 6, these province lines disappear. Is there any way to get these lines, even at Zoom 6? I've tried via the Style Wizard: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html?utm_medium=twitter, but without luck.. Thanks in advance!...

I have two circles that are positioned perfectly on the boarder of each other. They have position A and B (both vectors), and radii Ra and Rb. Now I add a third circle with radii Rc. How can I find the position vector C where the three circles are placed...

I've tried to draw a circle with Pyglet and I have failed. With beautiful and unexpected results, though. I have worked out the math: I have implemented the method: """ Pyglet utilities. Designed to ease drawing of primitives with Pyglet. """ # Dependencies import pyglet from math import sin, cos...

I have a mesh that represents portion of the surface of a sphere and I am having some trouble figuring out the UV coordinates for the verts. Given the generation code for the verts could someone explain / provide an example of how I can determine the uv coordinates? The...

This is a geometrical question based on a programming problem I have. Basically, I have a MySQL database full of latitude and longitude points, spaced out to be 1km from each other, corresponding to a population of people who live within the square kilometer around each point. I then want...

Given is a line (segment), defined by two vectors start(x,y) and end(x,y). I also have a point p(x,y), which is on either of the two areas separated by the line (i.e. it is not exactly on the line). How can I calculate the normal to the line that is facing...

I am working on an app which highly depends on geolocation and calculations based upon it. One of the views is a list view which gives a list of moving POI's behind the users location. +---------------------------+ +------ . ------+ +----- . -----+ +---- . [POI1] ----+ +--- . / ---+...

I'm having trouble even figuring out where to start with this. ANY help would be highly appreciated! Using the Corona SDK I want to draw a circle that will slowly fill as a percentage increases. The fill effect will follow the path of the circle, going anti-clockwise until the entire...

how to get the distance or radian between two point on the earth with lng and lat?