trigonometry

Angle between vector and list of vectors in R

ぃ、小莉子 提交于 2021-02-07 14:42:32
问题 When comparing two vectors it is simple to calculate the angle between them, but in R it is noticeably harder to calculate the angle between a vector and a matrix of vectors efficiently. Say you have a 2D vector A=(2, 0) and then a matrix B={(1,3), (-2,4), (-3,-3), (1,-4)}. I am interested in working out the smallest angle between A and the vectors in B. If I try to use min(acos( sum(a%*%b) / ( sqrt(sum(a %*% a)) * sqrt(sum(b %*% b)) ) )) it fails as they are non-conformable arguments. Is

Angle between vector and list of vectors in R

筅森魡賤 提交于 2021-02-07 14:41:12
问题 When comparing two vectors it is simple to calculate the angle between them, but in R it is noticeably harder to calculate the angle between a vector and a matrix of vectors efficiently. Say you have a 2D vector A=(2, 0) and then a matrix B={(1,3), (-2,4), (-3,-3), (1,-4)}. I am interested in working out the smallest angle between A and the vectors in B. If I try to use min(acos( sum(a%*%b) / ( sqrt(sum(a %*% a)) * sqrt(sum(b %*% b)) ) )) it fails as they are non-conformable arguments. Is

Need help for proper rectilinear projection of equirectangular panoramic image

南楼画角 提交于 2021-02-06 12:32:16
问题 With the algorithm below, when the projection plane is tangent to the equator (the center line of the equirectangular image), projected image looks rectilinear. But when the projection plane is tilted, (py0 != panorama.height/2), lines are warped. The two last "lines" in the algorithm below needs to be "rectified", in order to adjust px and/or py when the center line of the destination plane is not at the same level than the center line of the equirectangular image. // u,v,w : // Normalized

converting the difference in vectors to between 0 and 1

左心房为你撑大大i 提交于 2021-02-04 07:27:05
问题 I'm working with two unit vectors but not sure how to calculate this. I need it so that if they point in the same direction the answer is 1, opposite directions the answer is 0, perpendicular (either up or down) the answer is 0.5, etc. Examples: For two vectors (1,0) and (-1,0) (so, opposite vectors), the answer I get is 0. For two vectors (1,0) and (1/sqrt(2),1/sqrt(2)) (so, the unit vector pointing at a 45 degree angle) I get 0.25. For two vectors (0,1) and (-1,0) (so, perpendicular vectors

How to get 3D coordinates from distance, azimuth and elevation

青春壹個敷衍的年華 提交于 2021-01-29 17:56:57
问题 I'm working in a 3D environment (a 100x100x100 virtual cube) where each point is defined by its x, y and z position. We have two points: A with position x:20 y:35 z:40 and B x:50 y:40 z:85. Using this algo (https://gis.stackexchange.com/questions/108547/how-to-calculate-distance-azimuth-and-dip-from-two-xyz-coordinates) I'm able to find the distance, the azimuth and the elevation of B seen from A. let ax = 20; let ay = 35; let az = 40; let bx = 50; let by = 40; let bz = 85; let dx = bx-ax;

Sphere-plane collision resolve

↘锁芯ラ 提交于 2021-01-29 17:49:50
问题 I want to write a c++ program that will calculate collision between sphere and plane. The rule is that the angle of the falling object equals to angle of reflection. What do I have for sphere: //sphere coordinates and radius float x; float y; float z; float r; //sphere velocity vector projections float vx; float vy; float vz; Plane is described by plane equation coefficients: float A; float B; float C; float D; With sphere-plane collision detection I have no problem. But how to find velocity

compare angle and up in strange behavior

依然范特西╮ 提交于 2021-01-29 15:02:06
问题 i have a func to compare angles.. if the angles si between the range -5/+5deg from the starting heading this should return Color .green otherwise should return .orange. i simplify the project so it can be easy to use in swift Playground. here my fun: func convertToPositiveAngle(_ angle : Angle) -> Angle { var toRet = Angle(degrees: fmod(angle.degrees, 360)) if toRet.degrees < 0 { toRet.degrees += 360.0; } return toRet } let headingStart = 3.0 let currentHeading = 3.0 func centro(startHeading

Javascript function to find third point of triangle when all sides, angles and first two points are known

霸气de小男生 提交于 2021-01-27 17:46:14
问题 This has been asked before however I've found no satisfactory answers so I'm going to try and makes sure this is on topic and generates some good responses. This question should not be on maths.stackexchange because it's about the Javascript code required to complete the function I started below. Imagine the following triangle. Each point A, B and C have x and y coordinates and we know what these coordinates are for Ax, Ay, Cx and Cy. We also know the length of a, b and c and the angle of A,

maxima tex output to show brackets for sin and cos

久未见 提交于 2021-01-24 09:01:05
问题 I use maxima's tex output and would like to change the way it outputs sin(x). It currently does: tex(sin(x)); $$\sin x$$ But I would like to have brackets around the x, but not always; for instance, if i use this: sin(x/2) already has \left( and \right) tex(sin(x/2)); \begin{equation} \sin \left({{x}\over{2}}\right) \end{equation} is this possible, maybe with the texput function? 回答1: Well, if you are not adverse to putting in a little Lisp code: (%i1) :lisp (setf (get '%sin 'tex) nil) (%i1)

Rotating image with trigonometric functions

我只是一个虾纸丫 提交于 2021-01-07 07:00:28
问题 Hello I want to ratate image with only using trigonometric functions. Assume "q" as a "theta" y'=x*sin(q) + y(-tan(q/2))*sin(q)+y x'=x+2 y (-tan(q/2)) + x sin(q) (-tan^2(q/2)) + y x' and y' is going to be our new x and y values. I am quite new in image proccesiing but i wrote a code which i think is kind of right. In this example "theta" is considered "30 degrees" but i will develop the code and it will work for any other degrees... So basically, I want from u to find my misake or if the code