Find the coordinates in an isosceles triangle [closed] - geometry

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Given:
(x1,y1) = (0,0)
(x2,y2) = (0,-10)
Using the angle to C, how are the coordinates at C calculated?

Let A be the point (x1,y1) and B be the point (x2,y2).
AC must have length 10 since it is isosceles.
Let X the point on AB which a perpendicular line passes through C. AXC is a right angled triangle with hypotenuse AC. C has co-ordinates (-length(AX),length(XC)).
length(AX) = length(AC)*cos(theta) = 10*cos(theta)
length(XC) = length(AC)*sin(theta) = 10*sin(theta)
Therefore C has co-ordinates: (-10*cos(theta),10*sin(theta))

There are multiple valid answers to this question. The following coordinates all produce isosceles triangles:
(-10, 0)
(10, 0)
(-10, -10)
(10, -10)
(6, -8)
(-6, -8)
(8, -6)
(-8, -6)
(x, -5) | x != 0
And, as a matter of fact, this isn't a complete solution.
Without some hint as to what programming platform you intend to implement a solution in, we cannot help much more.

Related

Generic Computation of Distance Matrices in Pytorch [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have two tensors a & b of shape (m,n), and I would like to compute a distance matrix m using some distance metric d. That is, I want m[i][j] = d(a[i], b[j]). This is somewhat like cdist(a,b) but assuming a generic distance function d which is not necessarily a p-norm distance. Is there a generic way to implement this in PyTorch?
And a more specific side question: Is there an efficient way to perform this with the following metric
d(x,y) = 1 - cos(x,y)
edit
I've solved the specific case above using this answer:
def metric(a, b, eps=1e-8):
a_norm, b_norm = a.norm(dim=1)[:, None], b.norm(dim=1)[:, None]
a_norm = a / torch.max(a_norm, eps * torch.ones_like(a_norm))
b_norm = b / torch.max(b_norm, eps * torch.ones_like(b_norm))
similarity_matrix = torch.mm(a_norm, b_norm.transpose(0, 1))
return 1 - similarity_matrix
I'd suggest using broadcasting: since a,b both have shape (m,n) you can compute
m = d( a[None, :, :], b[:, None, :])
where d needs to operate on the last dimension, so for instance
def d(a,b): return 1 - (a * b).sum(dim=2) / a.pow(2).sum(dim=2).sqrt() / b.pow(2).sum(dim=2).sqrt()
(here I assume that cos(x,y) represents the normalized inner product between x and y)

Parabola and the corresponding point on the directrix [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Suppose we have the equation of the parabola (y = x^2). See the figure below:
suppose we have a point P on this parabola, where P=(-2,4). We know that the distance between any point on parabola (e.g. P) and the focus is equal to the distance
between the point P and the directrix.
My question is, What the corresponding point (e.g. P') of P on the directrix of the parabola, where the distance between the focus and P = distance between P and P'? What is the equation which takes a point on the parabola and return the corresponding point on the directrix
Since focus and directrix have equal distance from any point on the parabola, they in particular have equal distance from the origin (0,0). You may assume that distance fo be d, so the focus would be at (0,d) and the directrix would be the line y=-d.
For any other point on the parabola, the squared distance to the line is
(y+d)2 =
(x2+d)2 =
x4 + 2dx2 + d2
and the squared distance to the focus is
x2 + (y-d)2 = x2 + (x2-d)2 = x2 + x4 - 2dx2 + d2
These two expressions should be equal, so their difference should be zero:
(x4 + 2dx2 + d2) -
(x2 + x4 - 2dx2 + d2) =
(4d-1)x2
From this you can read d=1/4. So your directrix is y=-1/4 and your focus is (0,1/4).
The point on the directrix which corresponds to a point on the parabola is simply its orthogonal projection. So if you have P=(x,y)=(x,x2) on the parabola, then you get P'=(x,-d)=P(x,-1/4).

Find 2 point with same distance from A [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a math problem. I have location (x,y) of point A, B, and a number (x). I want to calculate the location of point C, D. CD is perpendicular with AB and AC = AD = x.
This is the picture describe my problem:
Can anyone help me on this?
Thanks
You did not specify a programming language, but from your previous questions it seems that
you have some experience with (Objective-)C and Core Graphics on iOS, so this would be
a solution using C and Core Graphics data structures:
// Your input data:
CGPoint A = ...
CGPoint B = ...
CGFloat x = ...
// Vector from A to B:
CGPoint vecAB = CGPointMake(B.x - A.x, B.y - A.y);
// Length of that vector:
CGFloat lenAB = hypotf(vecAB.x, vecAB.y);
// Perpendicular vector, normalized to length 1:
CGPoint perp = CGPointMake(-vecAB.y/lenAB, vecAB.x/lenAB);
CGPoint C = CGPointMake(A.x + x * perp.x, A.y + x * perp.y);
CGPoint D = CGPointMake(A.x - x * perp.x, A.y - x * perp.y);
Your question is similar to How do you find a point at a given perpendicular distance from a line? . If you want further mathemetical details, you can refer: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

The best way to map correlation matrix from [-1, 1] space to [0, 1] space [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
SO is warning me my question is likely to be closed, I hope they're wrong :)
My question: let you have a correlation matrix; you would like correlations which are next to 1 and -1 go towards 1, while those next to 0 stay there.
The simplest way is to use absolute values, e.g. if Rho is you correlation matrix then you will use abs(Rho).
Is there any way which is theoretically more correct than the one above?
As an example: what if I use Normal p.d.f. instead of absolute value?
Adjusted Rho = N(Rho, mu = 0, sigma = stdev(Rho))
where N is the Normal p.d.f. function.
Have you any better way?
What are strengths and weaknesses of each method?
Thanks,
Try this.
x <- runif(min = -1, max = 1, n = 100)
tr <- (x - min(x))/diff(range(x))
plot(x)
points(tr, col = "red")
You could also use a logit link function that guarantees the values to be between 0 and 1. But given that you're limited to values between -1 and 1, you would get only values in the range of ~[0.3, 1].

Get the position of the point that lies at 25% of a line? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a line with 2 points. I know the distance between the 2 points. I also calculated the angle of the line.
My target is to get a point that lies at 25% ot the line.
I calculate the y of this point with (dist/100)*25.
My only problem is calculating the x of the point. I suspect i have all the variables needed i only can't seem to find how to calculate the x. Does anybody know this?
You have a segment (not line) with endpoints P0 (coordinates x0,y0) and P1(x1,y1). New point P lies at this segment and distance |P0P| = 0.25 * |P0P1|, if their coordinates are:
x = x0 + 0.25 * (x1-x0)
y = y0 + 0.25 * (y1-y0)
It's just simple vector maths, no need for any angles or trig here.
startPos = (0,0)
endPos = (10,10)
fratcion = 0.25
distX = endPos.x - startPos.x
distY = endPos.y - startPos.y
pos.x = startPos.x + fraction*distX
pos.y = startPos.y + fraction*distY

Resources