I am trying to bounce a projectile off of a wall in Slick. When the wall is vertical or horizontal, I can just invert the x or y velocity of the projectile, but when this is not the case I am struggling. I found another answer to a similar question...

I am experimenting with creating high-performance, good-looking pencil tools using SVG paths. I am logging the mouse coordinates to draw a path. To get a high-fidelity path (accurate to the user's movements) I need to log a point for every pixel movement. This has a big disadvantage. It creates a...

This question already has an answer here: Test point for its position relative to the convex hull in log(n) 3 answers I've researched several algorithms for determining whether a point lies in a convex hull, but I can't seem to find any algorithm which can do the trick in...

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 am trying to programmatically create the 3D model of text with beveled or rounded corners. See the following image for an example. Another requirement is speed. It should be possible to create a model for a 10 letter word in less than 10s. OpenScad is to slow. I also...

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...

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...

We have a number of parallelepipeds in space, having all the edges parallel to the axes. Each parallelepiped is characterized by 6 integer values, the coordinates of two of its vertices (x1; y1; z1); (x2; y2; z2) with x1 < x2; y1 < y2 and z1 < z2; I have...

How can one efficiently test if an axis-aligned rectangle R intersects a nice quadrilateral Q? Nice means: Q is convex (not a chevron) and non-selfintersecting (not a bowtie, not degenerate). Just 2D. Just yes/no. I don't need the actual region of intersection. Edit: Q and R may be open or...

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 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...

Consider a large set of floating-point intervals in 1-dimension, e.g. [1.0, 2.5], 1.0 |---------------|2.5 [1.5, 3.6], 1.5|---------------------|3.6 ..... It is desired to find all intervals that contain a given point. For example given point = 1.2, algorithm should return the first interval, and if given point = 2.0, it should...

Problem: I have N (~100m) strings each D (e.g. 100) characters long and with a low alphabet (eg 4 possible characters). I would like to find the k-nearest neighbors for every one of those N points ( k ~ 0.1D). Adjacent strings define via hamming distance. Solution doesn't have to...

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...

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. This programming puzzle is taken from here on Leetcode Below is my attempt to solve it. /** * Definition for a point. * class Point { * int x; *...

In the diagram below all points are in 3D space (x, y, z) and in the same plane BC defines a vector with midpoint A PA should be perpendicular to BC, however I do not know how to find P I need to determine the angle between OA and PA...

I have a line drawn with a Graphics object. I want to rotate this line a certain amount of degrees based on how much the mouse is dragged. I can get the number of degrees i need to rotate it but how do i then rotate the line based on...

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...

The convex hull can be found by stretching a rubber band so that it contains all the points and then releasing it. So my question is : lets assume that we have a robot (a theoretical robot) to solve this problem. We give it the coordinates of our points (...

Given a matrix nx3 that represents n points in 3D space. All points lie on a plane. The plane is given by its normal and a point lying on it. Is there a Matlab function or any Matlabby way to find the area directly from the matrix? What i was...

Let us consider a set of near-regular grids in 2-D. These grids are adjacent (neighbouring grids have one or more same vertices) to the neighbouring grids. Here are the sample of 10 grids with the coordinates of the vertices (longitude,latitude) are as follows A<- lon lat [,1] [,2] [1,] 85.30754...

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...

aI have to create a function on MATLAB that performs the following task: Input: p polygon in the form p = [x1,y1; x2,y2; x3,y3; x4,y4...] s struct with the segment from A to B s = struct('A',[x,y],'B'[u,w]) Return: 1) An integer indicating how many intersections there are between the segment...

I'm trying to build a function in MATLAB, in which you input a segment (defined by two points) and a polygon (4-sides) by indicating on an array its vertices. I have the following code: function intersection = intersectSegmentPolygon (s, p) % Create a vector with X coords of vertices and...

I have a constructive solid geometry of ellipsoids that cut a cube. I need to compute the volume of the porous cube. Are there any opensource programs out there that can do this (preferably in python)?

Give two planar points p1=(a1,b1) and ô°p2=(a2,b2)ô° and a line y=0, design an algorithm to find the smallest circle that covers both points such that its center (xô°ô°, 0)ô° lies on ô°y=ô°0. There is no time or space requirement. Although this problem seems simple, but I think it's kinda tricky...

Below is the solution for ,https://www.hackerrank.com/challenges/stars for (int iStar1 = 0; iStar1 < n; iStar1++) { for (int iStar2 = iStar1 + 1; iStar2 < n; iStar2++) { int sum1 = 0; for (int iStar3 = 0; iStar3 < n; iStar3++) { long line1 = (long)(stars[iStar3].y - stars[iStar1].y) * (stars[iStar2].x...

i really need your help since that i am fighting with the unknown for some time now. I am trying to draw a parametric surface on java 3d. The surface is being drawn if i a use a point array. Here is the code : PointArray lsa=new PointArray(length, GeometryArray.COLOR_3|GeometryArray.NORMALS|GeometryArray.COORDINATES); float...

In a route planning algorithm, I'm trying to perform a filter on a list of nodes based on distance to another node. I'm actually pulling the lists from a crude scene graph. I use the term "cell" to refer to a volume within a simple scenegraph from which we've fetched...

I have created a small Raphael app to showcase my struggle. I created four handles which can be moved. A 'sheet' is covering the entire screen except for the square between the 4 handles. Whenever the handles are dragged the sheet is placed accordingly. What ends up happening is that...

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 am trying to emulate a pivot rotation(rotate an element around a certain point, instead around it's center), on an SVG group element. I have at my dispense only 2 tools: A function that can move an element to an x-y direction in steps. Let's call this moveElement(x,y); Another function...