#include <math.h>
#define pi 3.14159265358979323846
#define degreesToRadian(x) (pi * x / 180.0)
#define radiansToDegrees(x) (180.0 * x / pi)
CGFloat distanceBetweenPoints (CGPoint first, CGPoint second) {
CGFloat deltaX = second.x - first.x;
CGFloat deltaY = second.y - first.y;
return sqrt(deltaX*deltaX + deltaY*deltaY );
};
CGFloat angleBetweenPoints(CGPoint first, CGPoint second) {
CGFloat height = second.y - first.y;
CGFloat width = first.x - second.x;
CGFloat rads = atan(height/width);
return radiansToDegrees(rads);
//degs = degrees(atan((top - bottom)/(right - left)))
}
CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint line2End) {
CGFloat a = line1End.x - line1Start.x;
CGFloat b = line1End.y - line1Start.y;
CGFloat c = line2End.x - line2Start.x;
CGFloat d = line2End.y - line2Start.y;
CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
return radiansToDegrees(rads);
}
NSData *data=[NSData dataWithBytes:pbWkD length:pbWkL];
//*nsdata保存成文件,从文件播放声音
NSArray *paths1=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentsDirectory1=[paths1 objectAtIndex:0];
NSString *savedImagePath1=[documentsDirectory1 stringByAppendingPathComponent:@"test.wav"];
[data writeToFile:savedImagePath1 atomically:NO];
//将文件路径转换为nsurl
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:savedImagePath1];
m_player= [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
*/
//直接从nsdata播放声音
NSError *error;
m_player=[[AVAudioPlayer alloc] initWithData:data error:&error];
[m_player setVolume:volume];
//[m_player setVolume:2.0];
[m_player prepareToPlay];
我目前,在公司学习OA开发,可我不知道,它有没有前途,谁知道啊?