iOS牛顿摆 小球撞击 物理学仿真模拟

                        **第一次写博客有点激动呢**

牛顿摆模型
使用 UIDynamic 的方法就不叙述了
这里先讲一下 牛顿摆是经过计算的一个公式才能达到理想状态 由于我不知道公式 所以做出来不能完美的达成 一个小球落下来另一个小球飞起来

接下来直接上代码 代码中的描述还是很详细的

#import "ViewController.h"
#import "ContentView.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ContentView *view =[[ContentView alloc]initWithFrame:self.view.bounds];
    view.backgroundColor=[UIColor blueColor];
    [self.view addSubview:view];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

#import "ContentView.h"
#import "BallsView.h"
@interface ContentView(){
   
    UIDynamicAnimator *_animator;//仿真模拟器
    NSMutableArray *_arrayBalls;
    CGPoint _centers[100];//可变的小球中心坐标
    UISnapBehavior *_snapB;
    UIAttachmentBehavior *attachement1;
}
@end

static CGFloat radius=20;//小球半径
static 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值