度不是弧度 [英] degrees not radians

查看:60
本文介绍了度不是弧度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将数学函数设置为使用度数而不是

弧度?


我正在计算一些天文计算,一切都是在

度。所有这些转变让我有点疯狂!


Jeff

解决方案

" Jeff Thies" <无**** @ nospam.net>写道:

是否可以将数学函数设置为使用度数而不是弧度?
我正在计算一些天文计算,一切都在
中度。所有这些转换让我有点疯狂!




Nope。


仅在输入和输出时进行转换,并且将所有

中间结果存储在弧度测量中。


您可以定义一些辅助函数。请注意,我不知道是否已经犯了任何浮点滥用的罪行。


// m是一个角度以度为单位的度量

函数弧度(m){return m * Math.PI / 180.0; }


// m是以弧度表示的角度度量

函数度(m){return m * 180.0 / Math.PI; }


然后,如果你真的很绝望,你可以定义自己的

变体函数:


// m是以度为单位的角度度量

定义cosD(m){返回Math.cos(弧度(m)); }


但是不断转换和返回
转换并不是一个好主意。就像我说的那样,仅在输入和输出时进行转换。


-

Chris Jeris cj **** @ oinvzer.net 向域名申请(1 6 2 4)(3 7)回复。


>然后,如果你真的很绝望,你可以定义自己的

变体函数:

// m是以度为单位的角度度量
define cosD(m){return Math.cos(弧度(米)); }


我喜欢这个想法,但不能让它发挥作用。我收到一个错误:


缺失;在声明之前。 (在定义之后)

但是不断转换和回转转换并不是一个好主意。就像我说的那样,仅在输入和输出时进行转换。


我希望!我做得不够聪明!曾经看过月亮的位置计算?
我觉得没什么好摆弄的!


欢呼,

杰克

-
Chris Jeris cj****@oinvzer.net 向域名申请(1 6 2 4)(3 7)以进行回复。


" Jeff Thies" <无**** @ nospam.net>写道:

// m是以度为单位的角度度量
定义cosD(m){return Math.cos(radians(m)); }


我喜欢这个想法,但不能让它发挥作用。我收到一个错误:
失踪;在声明之前。 (在定义之后)




这是我有一个Scheme braino。将''define''替换为''function''。


-

Chris Jeris cj **** @ oinvzer.net 申请(1 6 2 4)(3 7)到域名回复。


Is it possible to set the Math functions to use degrees instead of
radians?

I''m working out some astronomical calculations and everything is in
degrees. All those conversions are driving me a bit crazy!

Jeff

解决方案

"Jeff Thies" <no****@nospam.net> writes:

Is it possible to set the Math functions to use degrees instead of
radians?
I''m working out some astronomical calculations and everything is in
degrees. All those conversions are driving me a bit crazy!



Nope.

Do your conversion only at input and output, and store all your
intermediate results in radian measure.

You could define some helper functions. Note that I don''t know
whether I''ve committed any sins of floating-point-misuse here.

// m is an angle measure in degrees
function radians(m) { return m * Math.PI / 180.0; }

// m is an angle measure in radians
function degrees(m) { return m * 180.0 / Math.PI; }

Then if you were really desperate you could define your own
variant functions:

// m is an angle measure in degrees
define cosD(m) { return Math.cos(radians(m)); }

but it is not a good idea to be constantly converting and back-
converting. Like I said, convert only at input and output.

--
Chris Jeris cj****@oinvzer.net Apply (1 6 2 4)(3 7) to domain to reply.


> Then if you were really desperate you could define your own

variant functions:

// m is an angle measure in degrees
define cosD(m) { return Math.cos(radians(m)); }
I like that idea but can''t get it to work. I''m getting an error:

missing ; before statement. (after the define)

but it is not a good idea to be constantly converting and back-
converting. Like I said, convert only at input and output.
I wish! I''m not smart enough to do that! Ever look at the calculations for
the Moon''s position? It''s nothing I feel like tinkering with!

Cheers,
Jeff

--
Chris Jeris cj****@oinvzer.net Apply (1 6 2 4)(3 7) to domain to reply.



"Jeff Thies" <no****@nospam.net> writes:

// m is an angle measure in degrees
define cosD(m) { return Math.cos(radians(m)); }


I like that idea but can''t get it to work. I''m getting an error:
missing ; before statement. (after the define)



This was me having a Scheme braino. Replace ''define'' by ''function''.

--
Chris Jeris cj****@oinvzer.net Apply (1 6 2 4)(3 7) to domain to reply.


这篇关于度不是弧度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆