java,arraylist,geometry,shape,graphics2d

Check out Playing With Shapes for some interesting ideas. It shows you how to create a Triangle using the Polygon class: Polygon triangle = new Polygon(); triangle.addPoint(0, 0); triangle.addPoint(15, 30); triangle.addPoint(30, 0); shapes.add( triangle ); It also shows how to make more complex shapes like stars and hexagons using a...

I found the solution to my problem by adding the following line: set pm3d depthorder ...

c++,geometry,maps,runtime-error

You've a very original approach here ! Nevertheless, a vertical line has a infinite slope and this is the problem here: dividing by 0 is not allowed. Alternative built on your solution (slope): ... int mpvertical=0; // a separate couner for verticals if (xi-x0) mp[(yi-y0)/(xi-x0))]++; else if (yi-y0) mpvertical++; //...

You're not giving a very clear description of the desired motion. Let's say you want the point to move a little bit in a random direction at each timestep, and your problem is translating the idea of a random direction into x and y increments. Let's say the little bit...

algorithm,math,geometry,polygon,intersection

You could just iterate over the edges of your polygon and check whether one of them intersect your square. If one does then you are done. Otherwise just test whether either 1) the center of the square belongs to the polygon 2) an arbitrary point in the polygon belongs to...

javascript,geometry,leaflet,mapbox

You can use turf-bezier to create an interpolated bezier line out of any LineString geometry.

Suppose you want to compute a point one fifth (or any amount) of the way along the cubic Bezier curve from pf1.StartPoint (P1) to arcs1.Point2 (P3) with the control point arcs1.Point1 (P2). You do it like this: Compute a point one fifth of the way along the straight line from...

you need to use atan2 (4-quadrant arc tangens) create reference plane basis vectors u,v must be perpendicular to each other and lie inside plane preferably unit vectors (or else you need to account for its size) so let N=N_T x N_R; ... reference plane normal where the rotation will take...

matlab,geometry,computer-vision,matlab-cvst,projection-matrix

If the intrinsics are not known, the result is ambiguous up to a projective transformation. In other words, if you use estimateUncalibratedRectification to rectify a pair of images, and then compute disparity and do the 3D reconstruction, then you will reconstruct the 3D scene up to a projective transformation. Straight...

You probably need a bit of PL/SQL code. declare l_geometry mdsys.sdo_geometry; begin -- Get the geometry from the table into the variable. select g3e_geometry into l_geometry from mytable where g3e_fid = 15463352; -- Now you can do whatever you want with it. l_geometry.sdo_ordinates(5) := 1.5; -- Write back to the...

You are trying to inflate your shape, which has been answered before: inflate/deflate discussion...

sql-server,oracle,ssis,geometry

I'd bet dollars to donuts that you can use SSIS for this, with a little coercion. Specifically, well-known text (WKT) is the standard representation for geospatial data. On the Oracle side, you can use Get_WKT() against your data to return the WKT. Then on the SQL side, you can use...

math,vector,language-agnostic,geometry

Normalize direction vector, if needed: Len = Sqrt( dirx^2 + diry^2 ) dx = dirx / Len dy = diry / Len then find endpoint: end_x = x0 + 40 * dx end_y = y0 + 40 * dy ...

There's an O(n log n)-time algorithm due to Preparata and Muller, 1979. It uses polar duality together with an efficient 3D convex hull algorithm. I'm sure that there exist implementations of it (qhull maybe?).

p01 and p02 are center coordinates (CenterX and CenterY) d01-d04 represent cosine and sine of rotation angle (or dx,dy components of unit-length direction vector) l01 and l02 are half-width and half-height of initial axis-aligned rectangle. sxi and syi are X and Y-coordinates of ith vertice. These coordinates are rounded toward...

java,swing,graphics,geometry,jpanel

There are some of things that can be made to simplify the calculation: Keep the vertices ordered, so that it is always clear how to calculate the vertex angles pointing away from the corner Furthermore, always draw the polygon to the same direction; then you can always draw the angles...

c++,parallel-processing,geometry,lines,euclidean-distance

The distance between two parallel lines will be the distance between the first (infinite) line and any point (say, P3) on the second line. Since you are working with coordinates, it's more convenient to use the vector representation of the formula than to try to express the line as an...

If you have the n points p[] in clockwise order, then to get the inward pointing normal to an edge between points p[i] and p[i+1] you rotate the vector p[i]->p[i+1] clockwise through 90 degrees. That is: double dx = p[i+1].x - p[i].x; // x component of edge double dy =...

math,geometry,line,pseudocode,angle

Let's define some notation: A := (a1, a1). B := (b1, b2). C := (c1, c2). Then the determinant D of the matrix 1 a1 a2 1 b1 b2 1 c1 c2 determines whether C lies left or right of the directed line AB [cf. Computational Geometry - Berg, van...

Compute the 3D hull in time O(n log n) and then, for each face, compute the distance from the point to the plane on which the face lies.

That function is called describeArc(), but is actually drawing a circular sector, not an arc. I agree it is kind of ugly because you are unnecessarily drawing - and overdrawing - most of the sector. And you will get issues with some of the colours bleeding around the edge of...

To do this with simple OpenGL, you'll need to use a finer tessellate of the cube. Instead of drawing each face with only two triangles, you subdivide it into smaller pieces. The easiest tessellation is to split the faces into smaller squares, and drawing them with triangle strips. If you...

geometry,computational-geometry,approximation

Thanks to Jongware, the answer was quite obvious. Because I'm dealing with Java, all the sin/cos parameters should be in radians. Fix: double newX = Math.sin(Math.toRadians(theta * i)) * RADIUS + I_OFFSET_X; double newY = Math.cos(Math.toRadians(theta * i)) * RADIUS + I_OFFSET_Y; Works like a charm...

javascript,geometry,computational-geometry,bezier,adobe-illustrator

Check, if all the control points of the curve are inside the ellipse. If so, your curve lies completely within the ellipse too.

java,arraylist,geometry,shape,graphics2d

How about instead of rotating a rectangle, you draw lines between 4 points inside a rectangle: the points: excuse my poor mspaint skills. but i hope u get what i mean. u take the top center, middle right, bottom center and middle left points and draw lines between those (using...

c++,math,rotation,grid,geometry

float x_old = p.x; float y_old = p.y; p.x = x_old * cos(a) - y_old * sin(a); p.y = x_old * sin(a) + y_old * cos(a); Of course, if you are rotating many points by the same angle, you will want to save the sin & cos, instead of calculating...

c#,order,geometry,polygon,intersection

iterate through the lines first in an outer loop, then for each line get the 2 points in the specific order you want. Modify your code to put the two found itxns in temporary list, instead of directly into intersections collection - then, in between the inner and outer loop...

geometry,coordinate-systems,divide-by-zero

When you calculate center point of an arc that is passing through 3 points, you definitely need to check if these points lies on the same line. But rewrite expression if (py2-py1)/(px2-px1) = (py3-py2)/(px3-px2) to avoid dividing Det = (py2-py1) * (px3-px2) - (py3-py2) * (px2-px1) if Det = 0...

opengl-es,geometry,opengl-es-2.0

The problem is when you add the points to the final arrays: for(int c1 = 0; c1 < points.size(); c1 += 3) { sphereVertices[c1] = points.get(c1)[0]; sphereVertices[c1+1] = points.get(c1)[1]; sphereVertices[c1+2] = points.get(c1)[2]; } instead of using the same index for both the array and the list us separate ones: for(int...

geolocation,geometry,geospatial

https://github.com/mongodb/mongo/blob/master/src/third_party/s2/s2latlng.cc#L37 GetDistance() return a S1Angle, S1Angle::radians() will return the radians. This belong to s2-geometry-library(google code will close,i export it to my github. Java)....

You need to compare the absolute values of the slopes. Compare |slope1| with |slope2| Programmatically, use the abs function. For a more precise answer, provide the programming language you are using....

javascript,jquery,html5,canvas,geometry

A bit of trigonometry will give you the rotated top-left corner point This assumes the rectangle is being rotated around its center point function rotatedTopLeft(x,y,width,height,rotationAngle){ // get the center of the rectangle (==rotation point) var cx=x+width/2; var cy=y+height/2; // calc the angle of the unrotated TL corner vs the...

ios,objective-c,geometry,calayer,uibezierpath

The problem is that you're using integers for your angles, but you're dealing with radians: - (void)createCircleWithStartAngle:(int)startAngle endAngle:(int)endAngle name:(NSString *)name; Use floating point (e.g. CGFloat) for your angles....

This is what the code is doing. Every point P in the segment AB can be described as: P = A + u(B - A) for some constant 0 <= u <= 1. In fact, when u=0 you get P=A, and you getP=B when u=1. Intermediate values of u will...

c++,geometry,quaternions,euler-angles

The quaternions -q and q are different; however, the rotations represented by the two quaternions are identical. This phenomenon is usually described by saying quaternions provide a double cover of the rotation group SO(3). The algebra to see this is very simple: given a vector represented by quaternion p, and...

matlab,image-processing,geometry,pixel,binary-image

Matlab is great for working with images thanks to the matrix syntax. It does also work with indices so most time you can avoid "iterating through pixels" (although sometimes you'll still have to). Instead of checking all the pixels within each circle, and having to detect how many pixels were...

Found a solution in the package oracle.spatial.util in SDOUTL.jar and SDOAPI.jar included in Oracle to convert from WKT to SDO_Geometry and vice-versa: String geom = "MULTIPOLYGON (..." byte[] bgeom = geom.getBytes(); WKT wkt = new WKT (); JGeometry jgeom = wkt.toJGeometry(bgeom); bgeom = wkt.fromJGeometry(jgeom); System.out.println(new String(bgeom, "UTF-8")); ...

My error was that I was assuming that the center of the inverted circle also respected OP x OP' = r2, but as the image below shows, it clearly does not. The solution was to calculate two points on the circle and reflect each one, then use half the distance...

android,animation,geometry,ripple

Start by learning about drawing Circles on Canvas: http://www.compiletimeerror.com/2013/09/introduction-to-2d-drawing-in-android.html#.VQAjCVXd_NE Once you have the hang of that just increase the size of the circle incrementally with each frame being drawn (and, optionally, fade the color or alpha value of the circle as it approaches the large end of the size range)...

One way to do this would be to: rotate the coordinate system so that the plane of interest lies in the x-y plane, and the normal vector n is aligned with the z-axis project the points onto the x-y plane by setting their z-components to 0 Set up the coordinate...

ios,objective-c,geometry,uiviewanimation,cashapelayer

try the following code, this worked for me. I think the issue was with setting the correct path. So please how I calculated the path in the below code. - (void)viewDidLoad { [super viewDidLoad]; circleRadius = 200.0f; CGPoint ptCenter = self.view.center; circle = [CAShapeLayer layer]; circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(ptCenter.x -...

c++,matrix,rotation,geometry,axis

OK, I'm going to take another stab at this. My first answer was for XYZ order of rotations. This answer is for ZYX order, now that I know more about how MathGeoLib works. MathGeoLib represents position vectors as column vectors v = [x y z 1]^T where ^T is the...

math,graphics,geometry,game-physics,intersection

As @NicoSchertler suggested in a comment, a solution is to take each triangle and clip it on all the planes. If there are no points left (or under 3 points, so it is not a triangle), the triangle intersects the polyhedron. This seems to work well.

This can be done using border-radius . But you'll have to set equal height and width of the image and give border-radius only for top and right. Demo: http://jsfiddle.net/lotusgodkk/GCu2D/728/ CSS: img { border-radius:50% 50% 0 0; height:600px; //sample width:600px; //sample } HTML: <img src="http://www.lorempixel.com/600/600/sports/1/" /> In case of unequal width...

you can test for line intersections this is O(n^2) with naive approach if you segmentate the lines into segments then the complexity became much better see Implementing Hoey Shamos algorithm with C# for this and other approaches in better complexities then O(n^2) you can exploit periodicity of loop closed...

python,opengl,geometry,trigonometry,pyglet

You need to change the degree to radian... (Degree/180)*pi is what you need

I recommend to use the Math.atan2 method and shift the range of its angle: int getArea(double xcoord, double ycoord , double radius) { if(xcoord*xcoord + ycoord*ycoord > radius*radius) return -1; double angle = Math.PI/2 - Math.atan2(ycoord, xcoord); // Need to suptract the angle from Pi/2 because we want 0 rad...

In the GIS world, polygons are formed using LinearRings, which are closed LineStrings. To be closed, the start and end points must be identical. So with the GIS convention, a triangle has four points, a square has five points, etc. More here....

algorithm,3d,geometry,distance,computational-geometry

Find affine transform M that translates this ellipse in axis-oriented one (translation by -p and rotation to align orientation vector r and proper coordinate axis). Then apply this transform to point p and check that p' lies inside axis-oriented ellipsoid, i.e. x^2/a^2+ y^2/b^2+z^2/c^2 <= 1

algorithm,geometry,computational-geometry

Each run(one run is executing all commands of the given string once) changes two things: the direction which the robot looks to and its position(that is, each run shifts it by some vector(the direction of this vector depends on the its initial direction before the run) and rotates it)....

You specified thetaLength=Math.PI*2 which will result in a full circle. If that circle is rotated you will get the geometry you described. I think you will want to write thetaLength=Math.PI instead....

javascript,geometry,2d,spatial,perspective

The perspective transformation you are describing is called foreshortening and I do suggest not only looking at my answer but also looking up more info on it because it is concept with various applications and can be solved for with varying methods. Keep in mind Javascript is not my forte...

matlab,vector,geometry,linear-algebra

You can use the Matlab function pca (see for example here). For example, you can determine the basis of your plane, the normal vectors to your plane and a point m on the plane as follows: coeff = pca(X); basis = coeff(:,1:2); normals = coeff(:,3:4); m = mean(X); To check...

algorithm,math,geometry,computational-geometry

The answer is to find the point that forms a triangle with sides lengths: Ra+Rb, Ra+Rc, Rb+Rc. That's known as solving by three sides, but you'll get 2 possible answers. The basic formula to use here is the law of cosines: c^2 = a^2 + b^2 - 2ab*cos(gamma) Let define...

You can use DB::raw() to do this: DB::table('table')->insert([ 'field' => DB::raw("SPECIAL_FUNC(X)"), ]); Examples: http://dev.mysql.com/doc/refman/4.1/en/point-property-functions.html http://dev.mysql.com/doc/refman/5.0/en/populating-spatial-columns.html...

Let's blue radius = R green radius = r unknown yellow radius is F and |BC| = P then |GB| = R + F, because radii to touch point are perpendicular to common tangent, so they are collinear, and for right-angle BGC triangle (R + F)^2 = (r + F)^2...

math,geometry,computational-geometry

What you have here is a 2d bilinear blended surface. For simplicity, let's change its coordinates to range from zero to one: u = 0.5 * (ξ + 1) v = 0.5 * (η + 1) In that case, the surface evaluator can be expressed as F(u, v) = P1...

I ended up coming up with what worked out to be a pretty good approximate solution, I think. Here is how it looks in PHP: //$p is an array of latitude, longitude, value, and distance from the centerpoint //$cx,$cy are the lat/lon of the center point, $cr is the radius...

You got the angles wrong. The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position. So, if...

The trouble is, it is not clear what your 2D point is, what you want the sub-square value as, etc. So a definitive answer is difficult. But anyway, I will make some assumptions and see if I am right about what you are asking... Assuming you had a point A...

android,algorithm,geometry,figure

You can make a method that takes in an angle and returns the point on the boundary at that angle from the center. This involves a little trigonometry, and cases for the square. To draw a line between the boundaries of two shapes, determine the angle of the difference vector...

algorithm,geometry,computational-geometry,mesh,3d-model

If a 3D object is "simple", meaning that it doesn't have holes, it satisfies Euler's Formula for Polyhedra, V - E + F = 2 where V is the number of vertices in the figure, E is the number of edges, and F is the number of faces. If you...

First, find the point at which the circle is touching the rectangle. You can do this by working out the angle of one of the long rectangle edges that is parallel with the line from the center of the circle to the point where it touches the rectangle. Take the...

lua,geometry,corona,geometry-surface

This sample from caronalabs.com forums shows how you might draw an arc, which provides the discrete algorithm you would need to do what you're asking: function display.newArc(group, x,y,w,h,s,e,rot) local theArc = display.newGroup() local xc,yc,xt,yt,cos,sin = 0,0,0,0,math.cos,math.sin --w/2,h/2,0,0,math.cos,math.sin s,e = s or 0, e or 360 s,e = math.rad(s),math.rad(e) w,h =...

javascript,math,geolocation,geometry,geo

I've had a couple of very good and interesting approaches to this problem. The most simple and effective one was to use a library for calculating a bearing between 2 LatLon points. I used GeoDesy's latlon-spherical.js and its .bearing() method to get the bearing from my to my POI relative...

Your question about converting into int values suggests that you are going to display the points in a pixel display, here indeed scaling them first with a double then floor (or ceil or round) the values. Also a simple cast will do the conversion: int pi.x = (int)pd.x; Or, much...

Your theta (in radians) is: double theta = Math.Atan2(y2 - y1, x2 - x1); The end point of a line for the specified x2 can be calculated as (x2, theta * (x2 - x1) + y1). Draw line between start point (x1, x2) and the end point above on a...

matlab,geometry,curve-fitting,polynomials

One possibility is to use numerical differentiation to find the tangent line at every point, and decide whether it passes "close enough" to the given point. However, one has to think hard about "close enough" to avoid getting either no matches or too many. Here is another approach: consider the...

So, this knocked ~30 seconds off the time it takes to process through 5000 iterations, so it seems a sufficient answer. What I did was create a struct Called line to use in place of the pair of points. That looks like this: public struct Line { public List<Point> Points...

Taking a look at your code, the problem is that you're attempting the "border-trick" on the li itself instead of a :before/:after pseudo-element. If you move the borders to a pseudo-element, it works. I've provided an example below. body, html { margin: 0; padding: 0; font-family: Helvetica, Arial, sans-serif }...

python,geometry,networkx,sympy

I found a solution that sped the process up by about 13x (for a polygon with 35 points (like the data listed above), the old method from the code in the question took about 4hours to find all line segments inside the polygon. This new method took 18 minutes instead.)...

I see the following issues: ar, x, and y are not initialized. The computation is wrong in the lines: x+=((p[i].first+p[i+1].first)*ar); y+=((p[i].second+p[i+1].second)*ar); You are missing one iteration of the loop by using: for(i=0;i<points-1;i++) Here's a version of the function that works for me: int main() { int points; scanf("%d",&points); pair<float,float>p[points]; int...

Use polar coordinates: find an internal point to the polygon as a reference, say (c,d); use atan2(x-c, y-d) for each vertex (x,y) of the polygon to get the polar angles from that internal point; then sort by the angles you get. If the polygon is convex, averaging the max and...

Your thinking is basically the right idea. You want to compare the sequence of angles in your test shape to the sequence of angles in a predefined shape (for each of your predefined shapes). Since the first vertex of your test shape may not correspond to the first vertex of...

math,javafx,geometry,coordinates

You can use the Math.atan2(dy, dx) to get the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). Later use it to convert it to degrees. import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.scene.shape.Line; import javafx.stage.Stage; public class Main extends Application {...

I would use the mid-point circle algorithm and see the array as a bitmap. I did this JavaScript implementation a while back, modified here to use an array as target source for the "pixel". Just note that a circle will produce odd widths and heights as the distance is always...

#include <cmath> // ... double angle = atan2(p2.y - p1.y, p2.x - p1.x); // ... If you want to, you can also make sure that p1 != p2, because if it is then you'll get a domain error....

matlab,math,geometry,computational-geometry

I will restate the problem with my own notation: Given two points P and Q on the surface of a sphere centered at C with radius r, find a new point T such that the angle of the turn from PQ to QT is A and the length of QT...

c++,geometry,rounding,cgal,convex

In the end I discovered the root of this problem was the fact that the convex hull contained lots of triangles, whereas my input shapes were often cube-shaped, making each quadrilateral region appear as 2 triangles which had extremely similar plane equations, causing some sort of problem in the algorithm...

The general answer is to project the point onto the line. One way to see it is to transform the point into the reference frame defined by your segment (p1 is the new origin (0, 0), p2 the new (1, 0)). Then, you get rid of the new y coordinate...

The angle function returns the angle between the two vectors. For example if one vector was a unit vector pointing left and the other was a unit vector pointing up then the angle would be 90 degrees. In the first case, the first vector (0, 0) does not have an...

javascript,geometry,computational-geometry,famo.us

Just play with 60 deg === PI/3: http://jsfiddle.net/coma/nk0ms9hb/ var circles = document.querySelectorAll('div.circles > div'); Array.prototype.forEach.call(circles, function (circle, index) { var angle = index * Math.PI / 3; circle.style.top = Math.sin(angle) + 'em'; circle.style.left = Math.cos(angle) + 'em'; }); I'm using ems to ease the calculations like 2 * radius ===...

actionscript-3,geometry,displayobject,angles

const radiance:Number=180/Math.PI; angle=-(Math.atan2(mouseX-panel.x, mouseY-panel.y))*radiance; I used minus because usually the orientation is reverse when you don't add minus. hope this helps....

javascript,canvas,rotation,geometry

You could manually implement a transformation matrix. This allows you to set up the matrix for both read and write, then apply it to the points returning absolute points with the new actual values without the need or hassle to make special code for each use-case. The formula for the...

You can use the fill function to get the shading that you desire. With a little bit of customization for your application I believe the following code will work, although some vectorization may be in order if the for loop slows your program too much. X = zeros(3,size(TC,1)); Y =...

google-maps,google-maps-api-3,geometry

one option would be to remove all the province lines from the styled map. Add them in with a FusionTablesLayer or KmlLayer var stateBorders = new google.maps.FusionTablesLayer({ query: { select: 'kml_4326', from: '19lLpgsKdJRHL2O4fNmJ406ri9JtpIIk8a-AchA' }, map: map, styles: [{ polygonOptions: { fillOpacity: 0.001, strokeColor: "000000", strokeWeight: 1, strokeOpacity: 1.0, fillColor: "FFFFFF"...

Let: A = (a,b) and B = (c,d) define the line segment P = (p,q) be the other point. Define: dot( (p,q), (r,s) ) == p*r + q*s Then the vector: v = ( c-a, d-b) defines the direction along the line segment. Its perpendicular is: u = (d-b, (-(c-a))...

merge,three.js,geometry,rendering,mesh

Use the matrix4 toolset for translation (and rotation if you want), then merge your geometrys: var geometry = new THREE.TorusGeometry( 11, 0.5, 16, 100 ); var mergeGeometry = new THREE.Geometry(); var matrix = new THREE.Matrix4(); for( i = 1; i <= 50; i++ ) { matrix.makeTranslation( 0, 3.4 * i,...

You can calculate 2d vectors cross product and look at its sign. Given two vectors v1 and v2 you can calculate 2d cross product as (v1.X*v2.Y) - (v1.Y*v2.X) If you have point (x, y) and line (x0, y0)-(x1, y1) then ((x-x0)*(y1-y0)) - ((y-y0)*(x1-x0)) is 2d vector cross product. It will...

merge,three.js,geometry,selection,octree

When setting up your octree make sure undeferred is set to true. Like this - octree = new THREE.Octree( { undeferred: true, depthMax: Infinity, objectsThreshold: 8, overlapPct: 0.15 } ); That should do the trick!...