简体   繁体   English

Perl-tan的未定义子例程

[英]Perl - Undefined subroutine for tan

Having an issue since don't understand why it's not working for tan, but is fine to work for cos and sin. 既然有一个问题,那就不明白为什么它不适合晒黑,但适合于cos和罪恶。 I would assume the issue is that it's undefined, hence the error message but why exactly does cos and sin work and not tan? 我认为问题在于它是未定义的,因此是错误消息,但是为什么cos和sin确实起作用而不是tan起作用? How would I then define a tan method? 然后我将如何定义tan方法? Sorry for the newbie question, I'm just trying to work out Perl. 对新手问题很抱歉,我只是在尝试Perl。

Error: 错误:

Undefined subroutine &Slic3r::Print::SupportMaterial::tan called at C:/Users/owner/Documents/Slic3r/lib/Slic3r/Print/SupportMaterial.pm line 945.

Tan Code: 验证码:

my $min_angle = 40;
my $min_radian = deg2rad($min_angle);
my $b = tan($min_radian);
@Z=map{$_/$b} @Z;

Cos and Sin Code: 余弦代码:

Polygon->new(map [ $circle_radius * cos $_, $circle_radius * sin $_ ]

Edit: Realised that a subroutine would need a function, however when looking at the Perl script I'm trying to integrate with the module, it works fine and doesn't have a method, just declared tan. 编辑:意识到一个子例程将需要一个函数,但是当我查看我试图与该模块集成的Perl脚本时,它可以正常工作并且没有方法,只是声明为tan。

sin and cos are builtin Perl functions , but tan is not. sincosPerl内置的函数 ,但是tan不是。 This is easily remedied with a simple declaration 只需简单声明即可轻松解决

sub tan { sin($_[0]) / cos($_[0]) }

or import a module that defines the tangent function 或导入定义切线函数的模块

use Math::Trig;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM