Trigonometry - intersection of vector, created from azimuth and elevation, with plane [closed] - intersection

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
So, look at the image. I think it is self-describing what I want to achieve.
The size of T is just for example.
P0 can be also more up.
Think the problem is, this computation counts on that the plane is perpendicular to P0 point. When B is directed closer to mid of the plane, then the P1 is more correct. T can be also rotated and placed differently in space.

You have point P0 and direction vector dirGlobal, they define parametric equation of the ray P0P1 (t is parameter)
X = P0.X + dirGlobal.X * t
Y = P0.Y + dirGlobal.Y * t
Z = P0.Z + dirGlobal.Z * t
Substitute these values in plane equation
A * X + B * Y + C * Z + D = 0
solve it for t and get intersection point

Related

How do you find the width of a circle from any given y position? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I was wondering if anybody knew how to find the width of a circle in any given y position. For example, lets say you have a unit circle, the radius is 100 units tall. Now three fourths the way up the circle, 25 units above the center of the circle, there is a line parallel to the x axis that extends from one edge of the circle to the other. it looks a bit like this.
How big is that line, and what algorithm did you use to solve this?
First, label what you know:
Looks like a triangle to me.
Now, solve for X and double it:
x^2 + 25^2 = 100^2 (Pythagorean theorem)
x^2 = 9375 (Simplify)
x = 96.8 (Square root both sides, now we know x)
Length of chord: 193.6 (Length of chord is 2 times x)
Here is a site that can help you: http://www.mathopenref.com/chord.html
Since you tagged your question with Scratch, here is a function to help you:

Rotation and movement in AS3 [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 4 years ago.
Improve this question
I want to make a minigame where the background (maze) is always rotating around the same point, an immovable playerMC that's in the middle of the stage. To get the rotation I am using two MCs, one parent, that I rotate, and one nested maze that I would like to move according to mouse/keyboard movement
Unfortunately, the x and y axes on the maze are moved so at 90deg any movement 'up' will change to 'right'.
I do realise sin and cos or translation matrix should do the trick, but for some reason I can't get it right.
Here is a short gif summarising my problem: http://blackdragonschronicles.strefa.pl/Public/Vertigo.gif
I would greatly appreciate any help in the matter
You could use a Matrix which solves this pretty nicely.
In my small example I have an movieclip called box sitting on the stage. Its pivot is in the top left corner (0,0). If I want to rotate the cube from the center I would first translate the matrix by half of its width and height. I then rotate it by some arbitrary angle, and finally apply the matrix transformation to my box.
var angle:Number = Math.PI/64;
var m:Matrix = new Matrix();
m.translate(-box.width >> 1, -box.height >> 1);
stage.addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void {
m.rotate(angle);
box.transform.matrix = m;
}
In the same spirit you could translate a matrix with your current world position. And rotate around that point.
m.translate(position.x, position.y);
You can learn more about Matrices in AS3 here.
Thanks to the link you provided, Iggy, I've managed to understand what and how I want to do it. I used an additional method that was made for situations like this. Here's the code
import flash.events.Event;
import flash.geom.Matrix;
import fl.motion.MatrixTransformer;
addEventListener(Event.ENTER_FRAME,eF);
//Set rotation pivot
var RotationAt:Point = new Point(player.x,player.y);
//Center the MC at the player/pivot
mc.x = player.x
mc.y = player.y
function eF(e:Event){
var my_matrix = mc.transform.matrix;//needs to be refreshed all the time
MatrixTransformer.rotateAroundExternalPoint(my_matrix,player.x,player.y,1);
mc.transform.matrix = my_matrix; // changes the rotation
}
Later I just needed to add code for ading/subtracting x and y with the mouse current position.
Thank you!

Calculate position of a point by give position and distance? [duplicate]

This question already has answers here:
Calculate second point knowing the starting point and distance
(4 answers)
Closed 9 years ago.
I have to move from a point A( lat, lng ) to point B( lat, lng1 ).
The latitude of the both points is a constant.
I know the distance between them ( in meters ), so i need the formula to find the longitude of point B.
How to find the longitude of point B ?
You have to add (or subtract, depending which point is on West side) the following:
distance_in_meters/Earth_radius_in_meters/cos(lat)*360degree/2/pi
or, alternatively:
distance_in_meters/Earth_equator_length_in_meters/cos(lat)*360degree
This works because the radius of circle of 'slice of Earth' (more precisely, intersection of Earth and plane perpendicular to Earth's axis, passing through point A), is equal to radius of Earth * cos(lat) - simple trigonometry. Then you just use the proportions:
360 degrees - 2pi R cos(lat)
x degree - d meters
x=360d/2/pi/R/cos(lat)
This is all assuming you use degrees.

Using 2 color functions in a mathematica matrix plot [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 9 years ago.
Improve this question
I'm trying to use 2 color functions within one matrix plot in mathematica. Is this possible to do?
For example, using a very simple matrix:
test = Partition[Table[i, {i, 1, 9}], 3]
I would like to make the even numbers vary in color increasing from white to red; and the odd numbers vary in color from grey to black.
How could I do this? I know how to get the whole matrix to vary in color, but no more than this.
You could try defining a ColorFunction as below.
CheckerPlot[array_?MatrixQ] :=
With[{len = Length[Flatten[array]]},
ArrayPlot[array,
ColorFunction->(If[EvenQ[#], Blend[{White, Red}, #/len],
Blend[{Gray,Black}, #/len]] &),
ColorFunctionScaling -> False]
]
Execute by using, for example,
CheckerPlot[Partition[Table[i, {i,1,36}], 5]]

Trigonometry - Calculate an angle based on a fixed central point [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 1000x1000 grid with a fixed point (p1) in the centre and a variable point (p2). How can I calculate, in degrees, the angle indicated in red? The vertical blue line will always be fixed as 0 degrees.
Many thanks in advance.
A few hints to guide you in understanding why the solutions you've seen/will see work...
Let p2 be sitting in the position (x,y) on your grid; What is the projection of p2 onto the x axis, or p2 onto the y axis?
Where is p1 located?
How do you determine the distance between two points on a coordinate axis?
What would pythagoras say the length of the line connecting p1 and p2 is?
What trigonometric facts do you know of that relate the sides of a triangle to an angle?
If we know cos(x) = a, then x = ...?
You can calculate the angle with the following formula:
if(x>0)
angle = cos^-1(y/(sqrt(x^2+y^2))
else
angle = 180 + cos^-1(y/(sqrt(x^2+y^2))
where x is the horizontal distance between p1 and p2 and y is the vertical.
arctan(p2.y/p2.x) + 90 works for the upper-left quadrant. Depending on how you want to calculate the other quadrants you can either use the same formula or use the inverse as abs(result - 180)