sin

PHP计算两个经纬度地点之间的距离

China☆狼群 提交于 2019-12-04 14:08:45
``` /** * 求两个已知经纬度之间的距离,单位为米 * * @param lng1 $ ,lng2 经度 * @param lat1 $ ,lat2 纬度 * @return float 距离,单位米 * @author www.Alixixi.com */ function getdistance($lng1, $lat1, $lng2, $lat2) { // 将角度转为狐度 $radLat1 = deg2rad($lat1); //deg2rad()函数将角度转换为弧度 $radLat2 = deg2rad($lat2); $radLng1 = deg2rad($lng1); $radLng2 = deg2rad($lng2); $a = $radLat1 - $radLat2; $b = $radLng1 - $radLng2; $s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137 * 1000; return $s; } ``` > 更多精彩文章请关注 [王明昌博客](https://www.wangmingchang.com) 来源: https://www.cnblogs.com/wmc1125/p

三角函数公式整理

最后都变了- 提交于 2019-12-04 03:39:48
诱导公式 奇变偶不变,符号看象限 \[ \begin{aligned} &\cos {\left(\pi + \alpha \right)} =-\cos \alpha\\ &\sin {\left( \pi + \alpha \right) } = -\sin \alpha\\ &\tan {\left( \pi + \alpha \right)} = \tan \alpha \end{aligned} \] \[ \begin{aligned} &\cos {\left(-\alpha \right)} =\cos \alpha\\ &\sin {\left(-\alpha \right) } = -\sin \alpha\\ &\tan {\left(-\alpha \right)} = -\tan \alpha \end{aligned} \] \[ \begin{aligned} &\cos {\left(\pi - \alpha \right)} =-\cos \alpha\\ &\sin {\left( \pi - \alpha \right) } = \sin \alpha\\ &\tan {\left( \pi - \alpha \right)} = -\tan \alpha \end{aligned} \] \[ \begin{aligned} &\cos {

每日一题_191113

折月煮酒 提交于 2019-12-04 01:46:54
已知椭圆 \(\mathit{\Gamma}: \dfrac{x^2}{4}+\dfrac{y^2}{2}=1\) ,过点 \(P(1,1)\) 作倾斜角互补的两条不同直线 \(l_1,l_2\) ,设 \(l_1\) 与椭圆 \(\mathit{\Gamma}\) 交于 \(A,B\) 两点, \(l_2\) 与椭圆 \(\mathit{\Gamma}\) 交于 \(C,D\) 两点. \((1)\) 若 \(P(1,1)\) 为线段 \(AB\) 的中点,求直线 \(AB\) 的方程; \((2)\) 记 \(\lambda=\dfrac{|AB|}{|CD|}\) ,求 \(\lambda\) 的取值范围. 解析: \((1)\) 法一 若记 \(P(x_0,y_0)\) ,则当 \(P\) 为弦 \(AB\) 的中点时,由中点弦方程可得直线 \(AB\) 方程为 \[ \dfrac{x_0x}{4}+\dfrac{y_0y}{2}=\dfrac{x_0^2}{4}+\dfrac{y_0^2}{2}.\] 因此所求直线方程为 \(x+2y-3=0\) . 法二 由题显然 \(AB\) 的斜率存在,设点 \(Q(x,y)\) 是直线 \(AB\) 上任意一个异于 \(P\) 点的的点,则由椭圆的垂径定理知 \(OP\) 直线的斜率与 \(PQ\) 直线的斜率乘积为 \(-

用Cython编译写出更快的Python代码

北战南征 提交于 2019-12-03 20:37:24
原文地址: http://www.behnel.de/cython200910/talk.html 以下为原文 About myself Passionate Python developer since 2002 after Basic, Logo, Pascal, Prolog, Scheme, Java, C, ... CS studies in Germany, Ireland, France PhD in distributed systems in 2007 Language design for self-organising systems Darmstadt University of Technologies, Germany Current occupations: http://codespeak.net/lxml/ IT transformations, SOA design, Java-Development, ... Employed by Senacor Technologies AG, Germany »lxml« OpenSource XML toolkit for Python »Cython« Part 1: Intro to Cython Part 1: Intro to Cython Part 2: Building Cython

IPv4,IPv6套接字地址结构

喜欢而已 提交于 2019-12-03 15:00:22
1.IPv4套接字地址结构 struct in_addr{   in_addr_t s_addr;//unsigned int }; struct sockaddr_in{   //uint8_t sin_len 这个字段可能在其他系统上有,我的系统是ubuntu 19.04 下面介绍的地址结构类似   sa_familiy_t sin_family;//unsigned short   in_port_t sin_port;//unsigned short   struct in_addr sin_addr;   unsigned char sin_zero[sizeof(struct sockaddr) - \ sizeof(sa_familiy_t) - sizeof(in_port_t) - sizeof(struct in_addr)]; }; sin_family指明了属于哪个协议族。sin_port指明了端口号(0-65535),sin_addr.s_addr指明了网络二进制字节序值。sin_zero可以从上面看出就是用了填充字节的,使得该结构和sockaddr通用套接字地址结构的大小相同。 2.通用套接字地址结构是什么? 通用套接字地址结构主要是为了方便处理不同协议族的套接字地址结构,即在需要传递套接字地址结构时通常采用struct sockaddr *sa作为形参

Can't bind to 'ngIf' since it isn't a known property of 'div' in production build

匿名 (未验证) 提交于 2019-12-03 10:09:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can able to run through locally. Getting error only in production build. I have used import { CommonModule } from '@angular/common'; imports: [ CommonModule ] Full error is shown below. client:101 Template parse errors:enter code here`Can't bind to 'ngIf' since it isn't a known property of 'div'. ("move" class="transport-remove">Remove</a></div> <div id="carTypeDiv_1" class="veh-inv-out" [ERROR ->]*ngIf="vehicleData.vesselType == 'road'"> <ul id="carTypeList_1" class="veh-slides"> "): VehicleDirective@10:52 Property binding ngIf not used

Why does multiprocessing use only a single core after I import numpy?

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am not sure whether this counts more as an OS issue, but I thought I would ask here in case anyone has some insight from the Python end of things. I've been trying to parallelise a CPU-heavy for loop using joblib , but I find that instead of each worker process being assigned to a different core, I end up with all of them being assigned to the same core and no performance gain. Here's a very trivial example... from joblib import Parallel,delayed import numpy as np def testfunc(data): # some very boneheaded CPU work for nn in xrange(1000):

What does the “s” mean in the structure?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here's a simple question. What's the meaning of the leading letter " s " in the sin_family, sin_port, sin_addr and sin_zero? struct sockaddr_in { short int sin_family; // Address family, AF_INET unsigned short int sin_port; // Port number struct in_addr sin_addr; // Internet address unsigned char sin_zero[8]; // Same size as struct sockaddr }; Thanks. 回答1: This comes from Berkeley, back when LSD was still legal. So very obvious in their naming choices :/ All kidding aside, this dates back to very early K&R C where structure members didn't

(004)spring容器报错expected single matching bean but found的原因及解放方法

纵然是瞬间 提交于 2019-12-03 08:11:14
  如果spring容器中存在某个类型的bean有多个,在根据名字获取bean的时候就会报expected single matching bean but found(期望匹配一个bean,但是发现多个)的错误,请看下面的实例。   示例1:   pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.edu.spring</groupId> <artifactId>spring</artifactId> <version>1.0.0</version> <name>spring</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com

Lat/Lon + Distance + Heading --&gt; Lat/Lon

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: So: I have the following function, adapted from a formula found online, which takes two lat/lon coordinates and finds the distance between them in miles (along a spherical Earth): public static double distance ( double lat1 , double lon1 , double lat2 , double lon2 ) { double theta = toRadians ( lon1 - lon2 ); lat1 = toRadians ( lat1 ); lon1 = toRadians ( lon1 ); lat2 = toRadians ( lat2 ); lon2 = toRadians ( lon2 ); double dist = sin ( lat1 )* sin ( lat2 ) + cos ( lat1 )* cos ( lat2 )* cos ( theta ); dist = toDegrees ( acos ( dist