math

How to detect collisions with a curve

霸气de小男生 提交于 2021-02-07 20:10:29
问题 I am making an HTML5 and Javascript platform game. At this moment all blocks of the map are handled as squares. This method is "ugly" when the block is not an exact square/rectangle. Check this image I made to get a better understand of my point: Case one: The "bottom bumper" is touching the square that envolves the block so the movement is stopped. Case two: If I use the same method as above, when the players jumps, the movement will be stopped before the "top bumper" even touches the block.

detecting arc and circle shapes in vector array with a range

谁说胖子不能爱 提交于 2021-02-07 19:22:10
问题 I have an array of 2d vertices and I want to detect if there are any arch or circle shapes in a array. Sometimes the values are not that precise and I need a small range. Here are the values. The 3rd verticle value value remains 0: verticle: -0.014848, -13.2684, 0 angle : 0.141274 verticle: -0.0174556, -4.84519, 0 angle : 90 verticle: 0, 0, 0 angle : 90 verticle: -9.53674e-07, 14.14, 0 angle : 40.7168 verticle: -12.1101, 14.0709, 0 angle : 7.94458 verticle: -12.0996, 10.6442, 0 angle : 0

Improving frequency time normalization/hilbert transfer runtimes

Deadly 提交于 2021-02-07 18:42:38
问题 So this is a bit of a nitty gritty question... I have a time-series signal that has a non-uniform response spectrum that I need to whiten. I do this whitening using a frequency time normalization method, where I incrementally filter my signal between two frequency endpoints, using a constant narrow frequency band (~1/4 the lowest frequency end-member). I then find the envelope that characterizes each one of these narrow bands, and normalize that frequency component. I then rebuild my signal

Probability of collision with truncated SHA-256 hash

耗尽温柔 提交于 2021-02-07 18:28:18
问题 I have a database-driven web application where the primary keys of all data rows are obfuscated as follows: SHA256(content type + primary key + secret), truncated to the first 8 characters. The content type is a simple word, e.g. "post" or "message" and the secret is a 20-30 char ASCII constant. The result is stored in a separate indexed column for fast DB lookup. How do I calculate the probability of a hash collision in this scenario? I am not a mathematician at all, but a friend claimed

Three colors triangles

大城市里の小女人 提交于 2021-02-07 12:52:38
问题 I am trying to make a code for this problem: (Source: https://www.codewars.com/kata/insane-coloured-triangles/train/c) A coloured triangle is created from a row of colours, each of which is red, green or blue. Successive rows, each containing one fewer colour than the last, are generated by considering the two touching colours in the previous row. If these colours are identical, the same colour is used in the new row. If they are different, the missing colour is used in the new row. This is

Three colors triangles

旧巷老猫 提交于 2021-02-07 12:51:47
问题 I am trying to make a code for this problem: (Source: https://www.codewars.com/kata/insane-coloured-triangles/train/c) A coloured triangle is created from a row of colours, each of which is red, green or blue. Successive rows, each containing one fewer colour than the last, are generated by considering the two touching colours in the previous row. If these colours are identical, the same colour is used in the new row. If they are different, the missing colour is used in the new row. This is

Random but most likely 1 float

北城以北 提交于 2021-02-07 12:37:46
问题 I want to randomize a float that so that There is 95% chance to be about 1 There is 0.01% chance to be < 0.1 or > 1.9 It never becomes 0 or 2 Is this possible by using Random.nextFloat() several times for example? A visual illustration of the probability: 回答1: You need to find a function f such that: f is continuous and increasing on [0, 1] f(0) > 0 and f(1) < 2 f(0.01) >= 0.1 and f(0.99) <= 1.9 f(x) is "about 1" for 0.025 <= x <= 0.975 And then just take f(Random.nextDouble()) For example,

Linear regression:ValueError: all the input array dimensions except for the concatenation axis must match exactly

主宰稳场 提交于 2021-02-07 10:52:43
问题 I am looking for a solution for the following problem and it just won't work the way I want to. So my goal is to calculate a regression analysis and get the slope, intercept, rvalue, pvalue and stderr for multiple rows (this could go up to 10000). In this example, I have a file with 15 rows. Here are the first two rows: array([ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [ 100, 10, 61, 55, 29, 77, 61, 42, 70, 73, 98, 62, 25, 86, 49, 68, 68, 26, 35

Comparing Faces using landmarks?

江枫思渺然 提交于 2021-02-07 09:13:11
问题 Lets say for each detected face, I have a set of landmarks like this (result from face detection API): "eye_left": { "x": 112.3, "y": 210.3 }, "eye_right": { "x": 217.5, "y": 205.5 }, "nose": { "x": 168.6, "y": 269.7 }, "mouth l": { "x": 119.1, "y": 307.6 }, "mouth_l": { "x": 119.1, "y": 307.6 }, "mouth r": { "x": 215, "y": 302.9 }, "mouth_r": { "x": 215, "y": 302.9 }, "pose": { "roll": -3.71, "yaw": 3.92, "pitch": -6.44 }, "b_ll": { "x": 74.3, "y": 184.6 }, "b_lm": { "x": 103.7, "y": 174.7 }

Ordering functions by Asymptotic Growth Rate

筅森魡賤 提交于 2021-02-07 09:00:41
问题 List the following functions in non-descending order of asymptotic growth rate. If two or more functions have the same asymptotic growth rate then group them together. g1(n) = n g2(n) = n^3 +4n g3(n) = 2n log(base 2) n g4(n) = 2^n g5(n) = 3 ^ (3 * log(base 3) n) g6(n) = 10^n I've been looking through several examples online but I have no idea how to do this, it just seems like a completely foreign concept to me. If anyone could help me, that would be much appreciated. how do I even calculate