大神verlet算法-js怎么用

拒绝访问 |
| 百度云加速
请打开cookies.
此网站 () 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(396ab4d173ec89e9-ua98).
重新安装浏览器,或使用别的浏览器君,已阅读到文档的结尾了呢~~
verlet js verlet velocity verlet javascript引擎 v8 javascript 引擎 javascript js js语法 javascript javascript物理引擎 javascript编写工具 javascript 编写
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
verlet-js是一个使用JavaScript编写的物理引擎
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口verlet-system
A tiny 2D/3D verlet physics system.
var Point = require('verlet-point')var array = require('array-range')var random = require('randf') create a world where points stay within window bounds var world = require('verlet-system')({
gravity: [0, 500],
min: [0, 0],
max: [width, height]}) create 500 points scattered around page var points = array(500).map(function() {
return Point({
position: [ random(0, width), random(0, height) ]
})}) draw our scene fuction render() {step the physics
world.integrate(points, dt)
drawPoints(points)}
Typically used alongside
By default, assumes 2D and points with [x, y]. You can require an explicit dimension like so:
var World2D = require('verlet-system/2d') points [x, y] var World3D = require('verlet-system/3d') points [x, y, z]
PRs for fixes/improvements welcome.
folder. The demos are
with beefy.
- mouse interactions
- using constraints
You can use , or just bare objects with the following structure:
var point = {
position: [x, y],
//required
previous: [x, y],
//required
acceleration: [x, y], //required
//optional, will default to 1.0
radius: 25
//optional, will default to 0.0}
Points with a mass of 0 are considered &unmovable&. radius is used for collision testing against min and max, but different applications may choose to ignore this.
bounded collisions
Collisions are ignored unless you set a min and/or max vector on the system (with the same number of components as the rest of your points). This will lead to particles 'bouncing' off the collision box. If a component is not a number, it will be ignored (i.e. act as infinity). For example, to allow particles to flow freely horizontally, but restrict them to the 2D window vertically, you might do this:
world.min = [null, 0]world.max = [null, height]
You can also specify a radius on points which will get used in the collision testing. See . By default, min and max are null objects, and no collisions are computed.
system = require('verlet-system')([opt])
Creates a new system with the specified options.
gravity a vector describing the gravity of this system, defaults to a zero vector
min the minimum bounds vector, defaults to null (i.e. negative infinity)
max the maximum bounds vector, defaults to null (i.e. positive infinity)
friction the air friction, defaults to 0.98
bounce the friction with collision edges, i.e. &bounciness&, defaults to 1.0
system.integrate(points, step)
Integrates the list of &points& with the given step (typically in seconds).
system.integratePoint(point, step)
Integrates a single &point&.
running demos
git clone /mattdesl/verlet-system.gitcd verlet-systemnpm install
if you haven't got these tools,
install them globally npm install browserify beefy uglify-js -g
now run or build any of the demos npm run line npm run triangulate npm run build-linenpm run build-triangulate
Should work with any tool that consumes CommonJS (i.e. jspm, DuoJS, browserify, webpack).
comparisons
This is not meant to be as feature-complete as choices like , , or . Some novel goals of this project:
works in 2D or 3D
no assumptions about rendering (i.e. works in WebGL, SVG, etc)
no assumptions about interactions or geometries
tiny and modular (3kb-6kb depending on what you require), e.g. you may not need constraints (as in the triangulate demo)
works on bare objects and arrays, easy to build your own systems on top of
uses a bounding box rather than just a Y value for &floor&
for details.
T22:56:18.736Z
is the latest
of 16 releases
Collaborators
downloads in the last day
downloads in the last week
downloads in the last month
Have an issue?
Try it out
Dependencies (4)下次自动登录
现在的位置:
& 综合 & 正文
异步调用Restful的WCF服务
上周在 blog上看到有人问是否能够异步调用Restful的WCF服务,下面便是具体实现异步调用Restful的WCF实现细节。通过本文的学习,有助于如下知识的掌握:
如何设定WCF的Restful支持
如何异步调用Restful的WCF服务
第一步:创建一个解决方案:AsyCallRestfulWcf,该解决方案包含下面四个项目:
AsyCallRestfulWcf.Contracts
WCF服务的契约项目,包含服务契约和数据契约的定义
AsyCallRestfulWcf.Service
WCF服务的具体实现
AsyCallRestfulWcf.Host
WCF服务的承载
AsyCallRestfulWcf.HttpClient
用Http 的方式异步调用WCF服务客户端
第二步:在项目AsyCallRestfulWcf.Contracts中创建服务契约IService.cs和数据契约Person.cs
Person.csusing S using System.Collections.G using System.T using System.Xml.S using System.Runtime.S
namespace AsyCallRestfulWcf.Contracts { [DataContract] public class Person { [DataMember] public string ID { get; set; } [DataMember] public string Name { get; set; } [DataMember] public int Age { get; set; } } }
IService.cs
IService.csusing S using System.Collections.G
using System.T using System.ServiceM
namespace AsyCallRestfulWcf.Contracts { [ServiceContract] public interface IService { [OperationContract] Person GetPerson(string id); } }
第三步:在项目AsyCallRestfulWcf.Service中创建服务实现类Service.cs
Service.cs
Service.csusing S using System.Collections.G using System.T using System.ServiceModel.W
namespace AsyCallRestfulWcf.Service { public class Service:Contracts.IService { [WebInvoke(Method = "*", UriTemplate = "GetPerson?id={id}")] public Contracts.Person GetPerson(string id) { System.Threading.Thread.Sleep(<span style="color: #00); Contracts.Person p = new AsyCallRestfulWcf.Contracts.Person(); p.ID = p.Name = "jillzhang"; p.Age = <span style="color: #; return } } }
在服务方法中,用System.Threading.Thread.Sleep(5000);模拟一个比较耗时的操作
第四步 实现WCF服务的承载项目:AsyCallRestfulWcf.Host
添加一个应用程序配置文件app.config和代码文件Programe.cs
App.config
App.config&?xml version="1.0" encoding="utf-8" ?& &configuration& &system.serviceModel& &services& &service name="AsyCallRestfulWcf.Service.Service"& &host& &baseAddresses& &add baseAddress="http://locahost"/& &/baseAddresses& &/host& &endpoint address="" binding="webHttpBinding" contract="AsyCallRestfulWcf.Contracts.IService" behaviorConfiguration="RestfulBehavior" name="webHttpBinding"& &/endpoint& &/service& &/services& &behaviors& &endpointBehaviors& &behavior name="RestfulBehavior"& &webHttp/& &synchronousReceive/& &/behavior& &/endpointBehaviors& &/behaviors& &/system.serviceModel& &/configuration&
Programe.cs
Programe.csusing S using System.Collections.G using System.T using System.ServiceM
namespace AsyCallRestfulWcf.Host { public class Programe { protected static void Main() { using (ServiceHost host = new ServiceHost(typeof(Service.Service))) { host.Open(); Console.WriteLine("服务已经启动!"); Console.Read(); }
在App.config中,要使WCF支持Restful,要使用的binding是webHttpBinding
第五步:实现异步调用的客户端:AsyCallRestfulWcf.HttpClient
添加windows窗体Form1.
后台代码为:
Form1.csusing S using System.Collections.G using ponentM using System.D using System.D using System.L using System.T using System.Windows.F
namespace AsyCallRestfulWcf.HttpClient { public partial class Form1 : Form { public Form1() { InitializeComponent(); } System.Net.WebC <img alt="" src="blo
&&&&推荐文章:
【上篇】【下篇】

我要回帖

更多关于 velocity verlet 的文章

 

随机推荐