4.5 million fps microscope camera powered by ultra-fast X-ray flash
august 2011 by squirrel
Remember those rugged gadgets we smashed to bits in super slow-mo? Well that spectacular footage was shot at around 1,500 frames per-second. A new camera system being built for the European XFEL (X-ray Free-Electron Laser) facility will record stunning clips of viruses and cells at an almost unimaginable 4.5 million fps. The camera is, in part, powered by a high speed flash created by the Science and Technology Facilities Council, that blasts its microscopic subjects with ultra-bright X-rays. The flashes themselves last as little as two femtoseconds, or 2x10^-15 seconds for you math nerds out there. When the whole apparatus is fired up in 2015 it could provide amazingly detailed, 3D images of individual molecules and answer some questions about the behavior of viruses and cells.4.5 million fps microscope camera powered by ultra-fast X-ray flash originally appeared on Engadget on Mon, 01 Aug 2011 14:58:00 EDT. Please see our terms for use of feeds.
Permalink Gizmag | STFC | Email this | Comments
camera
camera_flash
CameraFlash
cameras
europe
european_xfel
EuropeanXfel
flash
science
Science_and_Technology_Facilities_Council
ScienceAndTechnologyFacilitiesCouncil
stfc
x-ray_flash
X-ray_Free-Electron_Laser
X-rayFlash
X-rayFree-electronLaser
xfel
from google
Permalink Gizmag | STFC | Email this | Comments
august 2011 by squirrel
Create a terrain like the one in Tiny Wings with Flash and Box2D – Scrolling
july 2011 by squirrel
Some days ago I posted an example of a Box2D terrain like the Tiny Wings one.
Today I tried to make it endless and scrollable.
It’s very easy as it requires only a little modification to the original script.
Basically you have to attach a new hill to the right before the last hills will be completely visible , and remove the slices when they leave the screen to the left side, to save memory.
In this example, I am removing slices 20 pixels before they leave the screen, to make you see it works:
If you are afraid about Box2D world boundaries, I tested the terrain scrolling it for more than two million pixels, and everything worked like a charm.
Do you think it could be enough?
This is the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package {
import flash.display.Sprite;
import flash.geom.Point;
import flash.events.MouseEvent;
import flash.events.Event;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
public class Main extends Sprite {
private var world:b2World=new b2World(new b2Vec2(0,10),true);
private var worldScale:int=30;
private var nextHill:Number=140+Math.random()*200;
public function Main() {
world=new b2World(new b2Vec2(0,10),true);
debugDraw();
nextHill=drawHill(10,0,nextHill);
addEventListener(Event.ENTER_FRAME,updateWorld);
}
private function debugDraw():void {
var worldDebugDraw:b2DebugDraw=new b2DebugDraw();
var debugSprite:Sprite = new Sprite();
addChild(debugSprite);
worldDebugDraw.SetSprite(debugSprite);
worldDebugDraw.SetDrawScale(worldScale);
worldDebugDraw.SetFlags(b2DebugDraw.e_shapeBit|b2DebugDraw.e_jointBit);
worldDebugDraw.SetFillAlpha(0.5);
world.SetDebugDraw(worldDebugDraw);
}
private function drawHill(pixelStep:int,xOffset:Number,yOffset:Number):Number {
var hillStartY:Number=yOffset;
var hillWidth:Number=640;
var hillSliceWidth=hillWidth/pixelStep;
var hillVector:Vector.<b2Vec2>;
var randomHeight:Number=Math.random()*100;
if (xOffset!=0) {
hillStartY-=randomHeight;
}
for (var j:int=0; j<hillSliceWidth; j++) {
hillVector=new Vector.<b2Vec2>();
hillVector.push(new b2Vec2((j*pixelStep+xOffset)/worldScale,480/worldScale));
hillVector.push(new b2Vec2((j*pixelStep+xOffset)/worldScale,(hillStartY+randomHeight*Math.cos(2*Math.PI/hillSliceWidth*j))/worldScale));
hillVector.push(new b2Vec2(((j+1)*pixelStep+xOffset)/worldScale,(hillStartY+randomHeight*Math.cos(2*Math.PI/hillSliceWidth*(j+1)))/worldScale));
hillVector.push(new b2Vec2(((j+1)*pixelStep+xOffset)/worldScale,480/worldScale));
var sliceBody:b2BodyDef=new b2BodyDef ;
var centre:b2Vec2=findCentroid(hillVector,hillVector.length);
sliceBody.position.Set(centre.x,centre.y);
for (var z:int=0; z<hillVector.length; z++) {
hillVector[z].Subtract(centre);
}
var slicePoly:b2PolygonShape=new b2PolygonShape ;
slicePoly.SetAsVector(hillVector,4);
var sliceFixture:b2FixtureDef=new b2FixtureDef ;
sliceFixture.shape=slicePoly;
var worldSlice:b2Body=world.CreateBody(sliceBody);
worldSlice.CreateFixture(sliceFixture);
}
hillStartY=hillStartY+randomHeight;
return (hillStartY);
}
private function findCentroid(vs:Vector.<b2Vec2>, count:uint):b2Vec2 {
var c:b2Vec2 = new b2Vec2();
var area:Number=0.0;
var p1X:Number=0.0;
var p1Y:Number=0.0;
var inv3:Number=1.0/3.0;
for (var i:int = 0; i < count; ++i) {
var p2:b2Vec2=vs[i];
var p3:b2Vec2=i+1<count?vs[int(i+1)]:vs[0];
var e1X:Number=p2.x-p1X;
var e1Y:Number=p2.y-p1Y;
var e2X:Number=p3.x-p1X;
var e2Y:Number=p3.y-p1Y;
var D:Number = (e1X * e2Y - e1Y * e2X);
var triangleArea:Number=0.5*D;
area+=triangleArea;
c.x += triangleArea * inv3 * (p1X + p2.x + p3.x);
c.y += triangleArea * inv3 * (p1Y + p2.y + p3.y);
}
c.x*=1.0/area;
c.y*=1.0/area;
return c;
}
private function updateWorld(e:Event):void {
if (x%640==0) {
nextHill=drawHill(10,- x+640,nextHill);
}
world.Step(1/30,10,10);
world.ClearForces();
for (var currentBody:b2Body=world.GetBodyList(); currentBody; currentBody=currentBody.GetNext()) {
if (currentBody.GetPosition().x*worldScale<(x*-1)+20) {
world.DestroyBody(currentBody);
}
}
world.DrawDebugData();
x-=1;
}
}
}
Next time I think I am adding a little car… No need to download anything, just replace the code used in the original example.
Actionscript_3
Box2D
Flash
Game_design
from google
Today I tried to make it endless and scrollable.
It’s very easy as it requires only a little modification to the original script.
Basically you have to attach a new hill to the right before the last hills will be completely visible , and remove the slices when they leave the screen to the left side, to save memory.
In this example, I am removing slices 20 pixels before they leave the screen, to make you see it works:
If you are afraid about Box2D world boundaries, I tested the terrain scrolling it for more than two million pixels, and everything worked like a charm.
Do you think it could be enough?
This is the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package {
import flash.display.Sprite;
import flash.geom.Point;
import flash.events.MouseEvent;
import flash.events.Event;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
public class Main extends Sprite {
private var world:b2World=new b2World(new b2Vec2(0,10),true);
private var worldScale:int=30;
private var nextHill:Number=140+Math.random()*200;
public function Main() {
world=new b2World(new b2Vec2(0,10),true);
debugDraw();
nextHill=drawHill(10,0,nextHill);
addEventListener(Event.ENTER_FRAME,updateWorld);
}
private function debugDraw():void {
var worldDebugDraw:b2DebugDraw=new b2DebugDraw();
var debugSprite:Sprite = new Sprite();
addChild(debugSprite);
worldDebugDraw.SetSprite(debugSprite);
worldDebugDraw.SetDrawScale(worldScale);
worldDebugDraw.SetFlags(b2DebugDraw.e_shapeBit|b2DebugDraw.e_jointBit);
worldDebugDraw.SetFillAlpha(0.5);
world.SetDebugDraw(worldDebugDraw);
}
private function drawHill(pixelStep:int,xOffset:Number,yOffset:Number):Number {
var hillStartY:Number=yOffset;
var hillWidth:Number=640;
var hillSliceWidth=hillWidth/pixelStep;
var hillVector:Vector.<b2Vec2>;
var randomHeight:Number=Math.random()*100;
if (xOffset!=0) {
hillStartY-=randomHeight;
}
for (var j:int=0; j<hillSliceWidth; j++) {
hillVector=new Vector.<b2Vec2>();
hillVector.push(new b2Vec2((j*pixelStep+xOffset)/worldScale,480/worldScale));
hillVector.push(new b2Vec2((j*pixelStep+xOffset)/worldScale,(hillStartY+randomHeight*Math.cos(2*Math.PI/hillSliceWidth*j))/worldScale));
hillVector.push(new b2Vec2(((j+1)*pixelStep+xOffset)/worldScale,(hillStartY+randomHeight*Math.cos(2*Math.PI/hillSliceWidth*(j+1)))/worldScale));
hillVector.push(new b2Vec2(((j+1)*pixelStep+xOffset)/worldScale,480/worldScale));
var sliceBody:b2BodyDef=new b2BodyDef ;
var centre:b2Vec2=findCentroid(hillVector,hillVector.length);
sliceBody.position.Set(centre.x,centre.y);
for (var z:int=0; z<hillVector.length; z++) {
hillVector[z].Subtract(centre);
}
var slicePoly:b2PolygonShape=new b2PolygonShape ;
slicePoly.SetAsVector(hillVector,4);
var sliceFixture:b2FixtureDef=new b2FixtureDef ;
sliceFixture.shape=slicePoly;
var worldSlice:b2Body=world.CreateBody(sliceBody);
worldSlice.CreateFixture(sliceFixture);
}
hillStartY=hillStartY+randomHeight;
return (hillStartY);
}
private function findCentroid(vs:Vector.<b2Vec2>, count:uint):b2Vec2 {
var c:b2Vec2 = new b2Vec2();
var area:Number=0.0;
var p1X:Number=0.0;
var p1Y:Number=0.0;
var inv3:Number=1.0/3.0;
for (var i:int = 0; i < count; ++i) {
var p2:b2Vec2=vs[i];
var p3:b2Vec2=i+1<count?vs[int(i+1)]:vs[0];
var e1X:Number=p2.x-p1X;
var e1Y:Number=p2.y-p1Y;
var e2X:Number=p3.x-p1X;
var e2Y:Number=p3.y-p1Y;
var D:Number = (e1X * e2Y - e1Y * e2X);
var triangleArea:Number=0.5*D;
area+=triangleArea;
c.x += triangleArea * inv3 * (p1X + p2.x + p3.x);
c.y += triangleArea * inv3 * (p1Y + p2.y + p3.y);
}
c.x*=1.0/area;
c.y*=1.0/area;
return c;
}
private function updateWorld(e:Event):void {
if (x%640==0) {
nextHill=drawHill(10,- x+640,nextHill);
}
world.Step(1/30,10,10);
world.ClearForces();
for (var currentBody:b2Body=world.GetBodyList(); currentBody; currentBody=currentBody.GetNext()) {
if (currentBody.GetPosition().x*worldScale<(x*-1)+20) {
world.DestroyBody(currentBody);
}
}
world.DrawDebugData();
x-=1;
}
}
}
Next time I think I am adding a little car… No need to download anything, just replace the code used in the original example.
july 2011 by squirrel
related tags
Actionscript_3 ⊕ adobe ⊕ Box2D ⊕ buythis ⊕ camera ⊕ CameraFlash ⊕ cameras ⊕ camera_flash ⊕ europe ⊕ EuropeanXfel ⊕ european_xfel ⊕ flash ⊖ game ⊕ Game_design ⊕ html ⊕ html5 ⊕ procrastinate ⊕ science ⊕ ScienceAndTechnologyFacilitiesCouncil ⊕ Science_and_Technology_Facilities_Council ⊕ stfc ⊕ X-rayFlash ⊕ X-rayFree-electronLaser ⊕ x-ray_flash ⊕ X-ray_Free-Electron_Laser ⊕ xfel ⊕Copy this bookmark: