math

TypeError: object array may be self-referencing python

南楼画角 提交于 2020-01-17 18:02:12
问题 So, I ran into this error: temp7: 1.68219771725e-06 temp6: [[array([-60800056.33037408], dtype=object)]] Exception in thread Thread-4: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 223, in run self._callback(TimerEvent(last_expected, last_real, current_expected, current_real, last_duration)) File "/home/husky/catkin_ws/src/huskybot_ekf_v2/src/meas

Check if an integer is GCD of some elements in a given set

只愿长相守 提交于 2020-01-17 14:07:08
问题 Given a set of positive integers and an integer k . All of the elements in the set is divisible by k . How to check if k is greatest common divisor of some elements in the set? My idea: For every element a[i] in the set, I divide it by k . Then I get GCD of all of the element in the set (which was changed after I divided). If the GCD is equal to 1, then k is GCD of some elements in the set. I have make some test cases and I see it right. But the online judge doesn't accept. Please give me an

Check if an integer is GCD of some elements in a given set

风流意气都作罢 提交于 2020-01-17 14:07:08
问题 Given a set of positive integers and an integer k . All of the elements in the set is divisible by k . How to check if k is greatest common divisor of some elements in the set? My idea: For every element a[i] in the set, I divide it by k . Then I get GCD of all of the element in the set (which was changed after I divided). If the GCD is equal to 1, then k is GCD of some elements in the set. I have make some test cases and I see it right. But the online judge doesn't accept. Please give me an

Check if an integer is GCD of some elements in a given set

空扰寡人 提交于 2020-01-17 14:07:04
问题 Given a set of positive integers and an integer k . All of the elements in the set is divisible by k . How to check if k is greatest common divisor of some elements in the set? My idea: For every element a[i] in the set, I divide it by k . Then I get GCD of all of the element in the set (which was changed after I divided). If the GCD is equal to 1, then k is GCD of some elements in the set. I have make some test cases and I see it right. But the online judge doesn't accept. Please give me an

Distance between center to any point on edge of rectangle in javascript

╄→尐↘猪︶ㄣ 提交于 2020-01-17 13:48:20
问题 As you can see in above picture, suppose that there is a ray emitted from center and collides at edge of rectangle. so I want to calculate at which point it collides, so that I could be able to calculate distance between point on edge and center. What we know? width and height of rectangle a degree & b degree (as shown in above figure) centerX, centerY 回答1: Let's center is (0, 0) and ray angle is phi . Pseudocode: c = Cos(phi) s = Sin(phi) if Width * Abs(s) < Height * Abs(c) then x = Sign(c)

Distance between center to any point on edge of rectangle in javascript

旧巷老猫 提交于 2020-01-17 13:48:14
问题 As you can see in above picture, suppose that there is a ray emitted from center and collides at edge of rectangle. so I want to calculate at which point it collides, so that I could be able to calculate distance between point on edge and center. What we know? width and height of rectangle a degree & b degree (as shown in above figure) centerX, centerY 回答1: Let's center is (0, 0) and ray angle is phi . Pseudocode: c = Cos(phi) s = Sin(phi) if Width * Abs(s) < Height * Abs(c) then x = Sign(c)

gmpy2 log2 not accurate after 16 digits

眉间皱痕 提交于 2020-01-17 09:31:03
问题 When using log2() in gmpy2 it does not seem to be accurate after 16 digits. It seems to work fine at 15 digits but after that the answer is not correct using mpz(mpfr(2) ** mpfr(x)). Do I need change the precision? I thought python by itself would be accurate up to 53 digits. Additionally, is there a way in gmpy2 to use a logarithm operation in bases besides 10 and 2? For example, base 8 or 16. 回答1: The standard Python float type is accurate to 53 bits which is roughly 16 decimal digits.

How to calculate coordinates of the gunpoint

送分小仙女□ 提交于 2020-01-17 06:43:33
问题 Good whatever time of day! I have some sprite: A point has coordinates Actor.x; Actor.y . AB length = 96 BC length = 86 AC length = 42 All calculations are approximate, I made it with help the ruler in Photoshop. Sprite always towards mouse, angle (in radians) stores in Actor.direction variable. I draw sprite with scale 0.3 . All bullets toward mouse (that is Bullet.direction == Actor.direction ). I need to create bullets in the B point. How I can calculate coordinates of the B point with any

How to check if a number is an integer in Pari/GP?

僤鯓⒐⒋嵵緔 提交于 2020-01-17 06:18:12
问题 I'm trying to write an if statement like this if(denominator([(i-1)! + 1] / i)-1,print(hi),print(ho)) i can be any integer for example 10, when I set i to 10 it gives this error. ? [(x-1)! + 1] / x *** this should be an integer: [(x-1)!+1]/x ^----------- I really only need to check if [(x-1)! + 1] / x is an integer or not the denominator thing is what I came up with, I also tried Mod but couldn't get that working either. 回答1: It seems that you are confused with the names x and i . Please, see

Point inside Oriented Bounding Box?

☆樱花仙子☆ 提交于 2020-01-17 05:42:05
问题 I have an OBB2D class based on SAT. This is my point in OBB method: public boolean pointInside(float x, float y) { float newy = (float) (Math.sin(angle) * (y - center.y) + Math.cos(angle) * (x - center.x)); float newx = (float) (Math.cos(angle) * (x - center.x) - Math.sin(angle) * (y - center.y)); return (newy > center.y - (getHeight() / 2)) && (newy < center.y + (getHeight() / 2)) && (newx > center.x - (getWidth() / 2)) && (newx < center.x + (getWidth() / 2)); } public boolean pointInside