curve

How to calculate the nearest point of a line and curve? .. or curve and curve?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 17:49:53
问题 Given the points of a line and a quadratic bezier curve, how do you calculate their nearest point? 回答1: I just wanna give you a few hints, in for the case Q.B.Curve // segment : to get a fast enough computation, i think you should first think about using a kind of 'bounding box' for your algorithm. Say P0 is first point of the Q. B. Curve, P2 the second point, P1 the control point, and P3P4 the segment then : Compute distance from P0, P1, P2 to P3P4 if P0 OR P2 is nearest point --> this is

Calculating an area under a continuous density plot

一世执手 提交于 2019-12-04 13:21:35
问题 I have two density curves plotted using this: Network <- Mydf$Networks quartiles <- quantile(Mydf$Avg.Position, probs=c(25,50,75)/100) density <- ggplot(Mydf, aes(x = Avg.Position, fill = Network)) d <- density + geom_density(alpha = 0.2) + xlim(1,11) + opts(title = "September 2010") + geom_vline(xintercept = quartiles, colour = "red") print(d) I'd like to compute the area under each curve for a given Avg.Position range. Sort of like pnorm for the normal curve. Any ideas? 回答1: Calculate the

.animate with a curve

冷暖自知 提交于 2019-12-04 06:05:31
First take a look: The cat needs to move to the x in a curve . (see the arrow) When the cat hits the x, it should stay 10 seconds, and after that the cat should go back to o, again in a curve, and repeat. I tried it with this code: function curve() { $('#cat').delay(10000).animate({top: '-=20',left: '-=20'}, 500, function() { $('#cat').delay(10000).animate({top: '+=20', left: '+=20'}, 500, function() { curve(); }); }); } curve(); But the cat is moving like this: Is there a way to get the cat to move in this kind of curve? You can use easing to achieve that, by doing a compound movement :

Using cubiccurve in OpenLayers 2?

一个人想着一个人 提交于 2019-12-04 05:49:51
I want to use cubiccurve in openlayers 2.13, And I have added the necessary files, But when drawing the line is drawn instead of the curve. Files are available on the website: http://trac.osgeo.org/openlayers/ticket/1715#no1 Drawing curve is very important for us and I no way I could control my curve. Can one help me? <html> <head> <script src="http://dev.openlayers.org/OpenLayers.js" type="text/javascript"></script> <title>Ya Mahdi</title> <style> html,body { height: 99%; width: 99%; } #map { width: 100%; height: 100%; border: 1px solid black; } </style> <script> mmGetCurvePoints = function

Javascript canvas curve with fixed length

我与影子孤独终老i 提交于 2019-12-04 05:25:48
I want to draw any ( randomized ) curve, with given: start point end point curve length How can I do such a thing limited by canvas boundaries, plus the curve can not cross. I was trying to find some solution but I can't figure this out. Thanks for your time. Here is more detailed view of what I want to accomplish: This is Quadratic curve drawn on canvas. Everything is fine. Question is, how to draw this without all the points, just with the fixed length in pixels, random points, bounded by canvas size and non crossing. The code could look something like this: function fixedCurve( A, B, length

Finding Y given X on a Cubic Bezier Curve?

喜你入骨 提交于 2019-12-04 01:01:44
I need a method that allows me to find the Y-coordinate on a Cubic Bezier Curve, given an x-coordinate. I've come across lots of places telling me to treat it as a cubic function then attempt to find the roots, which I understand. HOWEVER the equation for a Cubic Bezier curve is (for x-coords): X(t) = (1-t)^3 * X0 + 3*(1-t)^2 * t * X1 + 3*(1-t) * t^2 * X2 + t^3 * X3 What confuses me is the addition of the (1-t) values. For instance, if I fill in the X values with some random numbers: 400 = (1-t)^3 * 100 + 3*(1-t)^2 * t * 600 + 3*(1-t) * t^2 * 800 + t^3 * 800 then rearrange it: 800t^3 + 3*(1-t)

How to create a faceted line-graph using ggplot?

淺唱寂寞╮ 提交于 2019-12-03 22:19:30
I have a data frame created with this code: require(reshape2) foo <- data.frame( abs( cbind(rnorm(3),rnorm(3, mean=.8),rnorm(3, mean=.9),rnorm(3, mean=1)))) qux <- data.frame( abs( cbind(rnorm(3),rnorm(3, mean=.3),rnorm(3, mean=.4),rnorm(1, mean=2)))) bar <- data.frame( abs( cbind(rnorm(3,mean=.4),rnorm(3, mean=.3),rnorm(3, mean=.9),rnorm(3, mean=1)))) colnames(foo) <- c("w","x","y","z") colnames(qux) <- c("w","x","y","z") colnames(bar) <- c("w","x","y","z") rownames(foo) <- c("n","q","r") rownames(qux) <- c("n","q","r") rownames(bar) <- c("n","q","r") foo <- cbind(ID=rownames(foo),foo) bar <-

How to convert quadratic bezier curve code into cubic bezier curve?

青春壹個敷衍的年華 提交于 2019-12-03 21:56:30
So I've recently picked up graphics programming and I wanted to compute a cubic Bézier curve. I found this excellent answer on quadratic Bézier but I don't know how to convert this to a cubic Bézier curve. polfosol ఠ_ఠ For cubic Bézier curve, as you see in the link you shared, the green lines are obtained from the same procedure as the quadratic one. the differences are: you have two green lines, and then you need to calculate a blue line based on them. So the for loop changes as: for( float i = 0 ; i < 1 ; i += 0.01 ) { // The Green Lines xa = getPt( x1 , x2 , i ); ya = getPt( y1 , y2 , i );

Point addition using Elliptic Curve calculations on Java Card

你说的曾经没有我的故事 提交于 2019-12-03 21:18:05
I have a smart card which supports JavaCard 2.2.2 and I would like to develop a signature with tickets on elliptic curve. To do that, I need to compute the sum of 2 points on an elliptic curve. I've read the JavaCard's API and I don't think it is possible, in fact there are things about elliptic curves but only for algorithms that are already developed (ECPrivateKey for ECDSA for example ...) But when you want to create an ECPrivateKey, you have to give the parameters which define the elliptic curve, so it is defined somewhere, right ? To put it in a nutshell, is it possible to develop a Java

How to create a curved SVG path between two points?

早过忘川 提交于 2019-12-03 16:31:46
I need to draw a symmetrically curved line between the centers of two circles . <svg> <circle class="spot" id="au" cx="1680" cy="700" r="0"></circle> <circle class="spot" id="sl" cx="1425" cy="525" r="0"></circle> <line id="line1" stroke-width="2" stroke="red"/> </svg> This is the code I wrote so far. < line > element should be replaced with a curved path . function drawNow() { let point1X = document.getElementById("au").getAttribute("cx"); let point1Y = document.getElementById("au").getAttribute("cy"); let point2X = document.getElementById("sl").getAttribute("cx"); let point2Y = document