BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #45572同步于 2010/11/3
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

求教math库函数

wabyrlt
2010/11/3镜像同步6 回复
#include<gl/glut.h> #include<math.h> #include<stdlib.h> #define pi 3.141592597 #define t 0.087266461 . . . void drawCircle(int x, int y, float r) { glBegin(GL_LINE_LOOP); for(int i = 0; i <= 2 * pi / t - 1; i++) glVertex2f(x + r * cos(t * i), y + r * sin(t * i)); glEnd(); } . . . if(btn == GLUT_RIGHT_BUTTON && state == GLUT_UP) { drawCircle(xp, yp, rx); glColor3f(0.0, 1.0, 0.0); glLogicOp(GL_COPY); rx = sqrt(pow(x - xp, 2) + pow(y - yp, 2)); glLogicOp(GL_COPY); drawCircle(xp, yp, rx); } 但提示1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(23) : error C3861: 'cos': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(23) : error C3861: 'sin': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(83) : error C3861: 'sqrt': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(83) : error C3861: 'pow': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(83) : error C3861: 'pow': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(108) : error C3861: 'sqrt': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(108) : error C3861: 'pow': identifier not found 1>f:\opengl\lineandcircle\lineandcircle\lineandlcircle.cpp(108) : error C3861: 'pow': identifier not found 请教各位这是怎么回事?如何解决?谢谢了!
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
guozi机器人#1 · 2010/11/3
跟命名空间有关不? 【 在 wabyrlt (wabyrlt) 的大作中提到: 】 : #include<gl/glut.h> : #include<math.h> : #include<stdlib.h> : ...................
wabyrlt机器人#2 · 2010/11/3
【 在 guozi 的大作中提到: 】 : 跟命名空间有关不? : 【 在 wabyrlt (wabyrlt) 的大作中提到: 】 : : #include<gl/glut.h> : ................... 文件是.cpp类型的,glut.h是关于opengl的头文件,其他是c++的库头文件,加上using namespace std好像也不起作用。
math机器人#3 · 2010/12/30
Linux下编译选项加上-lm,这样才能把我加上
Guilt机器人#4 · 2010/12/30
【 在 math 的大作中提到: 】 : Linux下编译选项加上-lm,这样才能把我加上 : -- 从错误信息来看lz是在windows下吧。。
ericyosho机器人#5 · 2010/12/30
首先确定,你要写的到底是C++代码,还是C代码 如果是C++的话,你得 #include <cmath>
wks机器人#6 · 2011/1/2
话说,math里面已经定义了常量M_PI