math

Calculate points coordinates of an arc

雨燕双飞 提交于 2021-01-29 04:52:22
问题 My question is probably more about maths rather than programming, but I hope that is not a problem. In my app, I am calculating some movement paths, consisting of pixel coordinates (only calculating, not displaying them). I am now trying to smoothen the turn, which are now too sharp, so I would like to use some arc here. I found how I could draw the exact arc I need, using code like this: e.Graphics.DrawArc(myPen, myPoint.X, myPoints.Y, 50, 50, 180, 90); Basically what I know are three points

Finding if n! + 1 is a perfect square

◇◆丶佛笑我妖孽 提交于 2021-01-29 03:30:44
问题 I'm trying to write a program to look for a number, n, between 0 and 100 such that n! + 1 is a perfect square. I'm trying to do this because I know there are only three so it was meant as a test of my Python ability. Refer to Brocard's problem. 回答1: For very large numbers it's better to avoid using floating point square roots altogether because you will run into too many precision issues and you can't even guarantee that you will be within 1 integer value of the correct answer. Fortunately

R Exponent Produces NaN

那年仲夏 提交于 2021-01-29 01:56:40
问题 I am running into an issue when I exponentiate floating point data. It seems like it should be an easy fix. Here is my sample code: temp <- c(-0.005220092) temp^1.1 [1] NaN -0.005220092^1.1 [1] -0.003086356 Is there some obvious error I am making with this? It seems like it might be an oversight on my part with regard to exponents. Thanks, Alex 回答1: The reason for the NaN is because the result of the exponentiation is complex, so you have to pass a complex argument: as.complex(temp)^1.1 [1]

Angles Between Continuous 2D Vectors

只谈情不闲聊 提交于 2021-01-28 23:01:24
问题 I'm having some trouble calculating the clockwise angles between continuous 2D vectors. My computed angles do not seem right when I compare them by eye on a plot. What follows is my process in R. If necessary, install and enable the "circular" package: install.packages('circular') library(circular) Generate a small data frame of 2D coordinates: functest <- data.frame(x=c(2,8,4,9,10,7),y=c(6,8,2,5,1,4)) Plot the points for reference: windows(height=8,width=8) par(pty="s") plot(functest, main =

Calculate difference between two angles

感情迁移 提交于 2021-01-28 18:11:59
问题 I realize this is probaby the most noob question of all times, but my mind is completely stuck. I have two angles, which represent the compass direction of two units, lets say unit1: 90.0 unit2: 45.0 If these differ more than 20 degrees, unit2 needs to take unit1's direction, with +/-20 degrees, so that unit1:90.0 unit2:70.0 I can figure out the difference in degrees between these two (signed) using angle = 180 - abs(abs(unit1 - unit2) - 180) but I need to know whether to adjust by +20 or -20

Pair-Tournament design algorithm

随声附和 提交于 2021-01-28 17:19:10
问题 I'm trying to build a Javascript function that takes as an input: array of players e.g. ["player1","player2","player3","player4"] (probably only equal number of players) and dynamically creates an array for a tournament design based on the following rules: each player partners no more than once with the same player every player has an equal amount of total matches the outputs would be an array containing arrays of matches with four entries each e.g. [player1, player2, player3, player4] stands

Pair-Tournament design algorithm

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 17:16:24
问题 I'm trying to build a Javascript function that takes as an input: array of players e.g. ["player1","player2","player3","player4"] (probably only equal number of players) and dynamically creates an array for a tournament design based on the following rules: each player partners no more than once with the same player every player has an equal amount of total matches the outputs would be an array containing arrays of matches with four entries each e.g. [player1, player2, player3, player4] stands

Pair-Tournament design algorithm

最后都变了- 提交于 2021-01-28 17:15:27
问题 I'm trying to build a Javascript function that takes as an input: array of players e.g. ["player1","player2","player3","player4"] (probably only equal number of players) and dynamically creates an array for a tournament design based on the following rules: each player partners no more than once with the same player every player has an equal amount of total matches the outputs would be an array containing arrays of matches with four entries each e.g. [player1, player2, player3, player4] stands

Pair-Tournament design algorithm

强颜欢笑 提交于 2021-01-28 17:09:48
问题 I'm trying to build a Javascript function that takes as an input: array of players e.g. ["player1","player2","player3","player4"] (probably only equal number of players) and dynamically creates an array for a tournament design based on the following rules: each player partners no more than once with the same player every player has an equal amount of total matches the outputs would be an array containing arrays of matches with four entries each e.g. [player1, player2, player3, player4] stands

Pair-Tournament design algorithm

安稳与你 提交于 2021-01-28 17:09:39
问题 I'm trying to build a Javascript function that takes as an input: array of players e.g. ["player1","player2","player3","player4"] (probably only equal number of players) and dynamically creates an array for a tournament design based on the following rules: each player partners no more than once with the same player every player has an equal amount of total matches the outputs would be an array containing arrays of matches with four entries each e.g. [player1, player2, player3, player4] stands