math

How do you pin point the location of a user with 3 nodes, using Triangulation?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 19:34:05
问题 I am trying to find a user through their Bluetooth strength (RSSI value). I have 3 Raspberry PIs, each gathering the signal strength of the user. Lets say the nodes returned: node1 = 65 node2 = 70 node3 = 75 How would I find the user through triangulation and pin point them on a map, and output the RSSI value? I have researched Trilateration and Ceva's Theorem but do not know how to implement them. I am unsure on how to locate the nodes in an environment, do I give the main node a location of

what is “modf()” (a math function from C/C++ etc.) shorthand for?

偶尔善良 提交于 2021-02-18 18:54:42
问题 In C and C++, the modf function can break floating number into fractional and integral parts. I'm curious about what does "modf" stand for. What is it shorthand for? 回答1: what is modf() shorthand for? The function breaks a floating point number up into whole number and fractional parts. Looking at the 1989 definition (I do not find it in K & R 1st Ed.)... The modf function break the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores

Shader that transforms a mercator projection to equirectangular?

早过忘川 提交于 2021-02-18 16:55:14
问题 I am trying to make a shader in Unity taking a mercator projection texture as a source and converting it to an equirectangular projection texture . Input example: Output example: This example does the opposite with an equirectangular as source. If you look at the source of the above example: // mercator float latClamped = clamp(lat, -1.4835298641951802, 1.4835298641951802); float yMerc = log(tan(PI / 4.0 + latClamped / 2.0)) / PI2; float xMerc = xEqui / 2.0; vec4 mercatorPos = vec4(xMerc,

How to calculate square root in sqlite

こ雲淡風輕ζ 提交于 2021-02-18 09:01:56
问题 I need to calculate an euclidean distance in a sqlite database. Does anyone know how to calculate square roots in sqlite beside writing and loading a dynamic library for math functions? I am close to resorting to the fast inverse square root algorithm in here http://en.wikipedia.org/wiki/Fast_inverse_square_root though it might to turn into more fun than I need right now. And as a side note, it'd be great to figure out how to do power (which is the generalized question, and is cleaner coding

Subtract Unless Negative Then Return 0

帅比萌擦擦* 提交于 2021-02-18 08:53:42
问题 I'll preface with, this is solely to satisfy my curiosity rather than needing help on a coding project. But I was wanting to know if anyone knows of a function (particularly in python, but I'll accept a valid mathematical concept) kind of like absolute value, that given a number will return 0 if negative or return that number if positive. Pseudo code: def myFunc(x): if x > 0: return x else: return 0 Again, not asking the question out of complexity, just curiosity. I've needed it a couple

Performance of different math functions in x86?

跟風遠走 提交于 2021-02-18 06:31:19
问题 I am writing a 3D collision, and want to know the difference in performance of basic math functions like + - * / sqrt pwr trigonometry like sin cos tan arcsin.. I heard it depends on many other things so I just want to get a rough idea about which one is slower and need to avoid while finding different ways to solve the problem. Also I want to know the order and the magnitude of the difference Thanks Edit: I write in VC++ for x86. But knowledge in other architectures and general picture are

Radius of projected sphere in screen space

不打扰是莪最后的温柔 提交于 2021-02-17 22:10:49
问题 I'm trying to find the visible size of a sphere in pixels, after projection to screen space. The sphere is centered at the origin with the camera looking right at it. Thus the projected sphere should be a perfect circle in two dimensions. I am aware of this 1 existing question. However, the formula given there doesn't seem to produce the result I want. It is too small by a few percent. I assume this is because it is not correctly taking perspective into account. After projecting to screen

Radius of projected sphere in screen space

蓝咒 提交于 2021-02-17 22:09:41
问题 I'm trying to find the visible size of a sphere in pixels, after projection to screen space. The sphere is centered at the origin with the camera looking right at it. Thus the projected sphere should be a perfect circle in two dimensions. I am aware of this 1 existing question. However, the formula given there doesn't seem to produce the result I want. It is too small by a few percent. I assume this is because it is not correctly taking perspective into account. After projecting to screen

Use scipy.integrate.quad with Tensorflow

ぐ巨炮叔叔 提交于 2021-02-16 15:30:11
问题 I am trying to use scipy.integrate.quad with Tensorflow as following. time and Lambda are two Tensors with shape (None, 1). def f_t(self, time, Lambda): h = Lambda * self.shape * time ** (self.shape - 1) S = tf.exp(-1 * Lambda * time ** self.shape) return h * S def left_censoring(self, time, Lambda): return tf.map_fn(lambda x: integrate.quad(self.f_t, 0.0, x[0], # it is not a float before evaluation args=(x[1],)), tf.concat([time, Lambda], 1)) However, I get an error as below: File "J:

Convert Double to Scientific Notation in swift

故事扮演 提交于 2021-02-16 07:50:59
问题 I am trying to convert a given double into scientific notation, and running into some problems. I cant seem to find much documentation on how to do it either. Currently I am using: var val = 500 var numberFormatter = NSNumberFormatter() numberFormatter.numberStyle = NSNumberFormatterStyle.ScientificStyle let number = numberFormatter.numberFromString("\(val)") println(number as Double?) // Prints optional(500) instead of optional(5e+2) What am I doing wrong? 回答1: You can set NumberFormatter