math

Find the arc of the intersection between circle and rectangle

只愿长相守 提交于 2020-01-24 21:06:28
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Find the arc of the intersection between circle and rectangle

…衆ロ難τιáo~ 提交于 2020-01-24 21:06:05
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

How does a 32bit computer work with large bit numbers? Ex. 512bit integers [closed]

六眼飞鱼酱① 提交于 2020-01-24 16:16:24
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have been reading an article on cryptography, and I thought to myself "How does a 32bit computer actually perform operations on a 512bit value, or even a 64 bit value?" Would anyone be able to point me in the

How does a 32bit computer work with large bit numbers? Ex. 512bit integers [closed]

白昼怎懂夜的黑 提交于 2020-01-24 16:16:23
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have been reading an article on cryptography, and I thought to myself "How does a 32bit computer actually perform operations on a 512bit value, or even a 64 bit value?" Would anyone be able to point me in the

How to use scientific notation in js?

风流意气都作罢 提交于 2020-01-24 14:14:48
问题 var a = 5.0; var b = a * 10e-12; b *= 10e+12 print(b) Why b equals 500 instead of 5? As far as I know 10^(-12) equals to 1/(10^12), how can i rewrite the code? 回答1: Because math. 10e1 is 100 and 10e-1 is 1 . 10e1 * 10e-1 is 100 . 10e2 * 10e-2 is 100 . 10e3 * 10e-3 is 100 . You can very easily extend this to figure out that 10eN * 10e-N is always going to be 100 . If you want actual scientific notation, as in 1 * 10 ^ 2 , you want 1e12 and 1e-12 . 回答2: 10 -12 × 10 12 = 1 But what you wrote

Element by element tensor multiplication in python

泪湿孤枕 提交于 2020-01-24 13:17:27
问题 I am trying to solve a problem in computational algebra using python. Basically given two sets, say A={a,b} and B={e} , I need to compute the element by element tensor products and get a final set say C={a\tensor{e},b\tensor{e}} containing these products of elements. I can do an element by element multiplication using arrays with numbers but I can't do an element by element tensor multiplication of letters instead of numbers. 回答1: Not sure if I understood correctly, this below code multiplies

Stochastic Differential Equations (SDE) in 2 dimensions

旧时模样 提交于 2020-01-24 10:42:05
问题 I am working on stochastic differential equations for the first time. I am looking to simulate and solve a stochastic differential equations in two dimensions. The model is as follows: dp=F(t,p)dt+G(t,p)dW(t) where: p is a 2-by-1 vector: p=(theta(t); phi(t)) F is a column vector: F=(sin(theta)+Psi* cos(phi); Psi* cot(theta)*sin(phi)) G is a 2-by-2 matrix: G=(D 0;0 D/sin(theta)) Psi is a parameter and D is the diffusion constant I wrote code as follows: function MDL=gyro_2dim(Psi,D) % want to

Unsupported operand types [closed]

南楼画角 提交于 2020-01-24 10:01:13
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I am working on a shopping cart function for a website and have stumbled across this error: Fatal error: Unsupported operand types in ... on line 77 I

How to know coordinates in a real image from a scaled image

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-24 09:25:13
问题 First of all thanks for your time reading my question :-) I have an original image (w': 2124, h': 3204) and the same image scaled (w: 512, h: 768). The ratio for width is 4.14 (rw) and the ratio for height is 4.17 (rh). I'm trying to know the coordinates (x', y') in the original image when I receive the coordinates in the scaled image (x, y). I'm using the formula: x' = x * rw and y' = y * rh . But when I'm painting a line, or a rectangle always appears a shift that is incremented when x or y

Compute all differences possibilities in a vector

不想你离开。 提交于 2020-01-24 09:00:28
问题 Let's say I have a short vector x = [a,b,c,d,e]; What would be the best way to compute all the difference between members of the vector as: y = [e-d e-c e-b e-a d-e d-c d-b d-a c-e c-d c-b c-a b-e b-d b-c b-a a-e a-d a-c a-b]; Thanks in advance 回答1: To give that exact matrix, try: x = [1;2;3;4;5]; %# note this is a column vector (matrix of rows in general) D = squareform( pdist(x,@(p,q)q-p) ); U = triu(D); L = tril(D); y = flipud(fliplr( L(:,1:end-1) - U(:,2:end) )) result in this case: y = 1