Fractal generation from infinite sum - graphics

I found a project description on a course website for computer graphics. I am trying to complete the project for fun.
Here is the link to the problem description:
http://www.pdfhost.net/index.php?Action=Download&File=901bc7785bef41364b3a40f6f4493926
Below is my code. The problem I am running in to is that the terms of the series grow so fast I can't map the points to the screen correctly. From the problem description it says the points will be mappable within a -2 - 2 square but the difference in value between the points is so huge that normalizing by the largest would collapse most of the points to a single pixel.
I assume I have a fundamental misunderstanding that I can't identify. Any help or insight would be appreciated!
int w = 800, h = 600;
int numTimes = 10, cSize = 5;
float xr = 2, yr = 2;
void setup() {
size(w,h);
}
void draw() {
background(255);
Complex v = new Complex(mouseX*(xr/w) - (xr/2), mouseY*(yr/h) - (yr/2));
Complex[] exps = new Complex[numTimes];
for (int i = 0; i < numTimes; i++) {
exps[i] = complexExp(v,i);
}
ellipse(w/2, h/2, cSize, cSize);
for (int i = 0; i < numTimes; i++) {
drawSeries(new Complex(0,0), exps, i, i);
}
}
void drawSeries(Complex vToDraw, Complex[] exps, int count, int clrTrunc) {
if (count == 0) {
Complex v = exps[0];
float progress = float(clrTrunc) / float(numTimes);
fill(255*progress, 180, 255 - 255*progress);
vToDraw.add(v);
ellipse(vToDraw.r*(w/xr) + (w/2), vToDraw.i*(h/xr) + h/2, cSize, cSize);
vToDraw.sub(v);
vToDraw.sub(v);
ellipse(vToDraw.r*(w/xr) + (w/2), vToDraw.i*(h/xr) + h/2, cSize, cSize);
} else {
Complex v = exps[count];
vToDraw.add(v);
drawSeries(vToDraw, exps, count - 1, clrTrunc );
vToDraw.sub(v);
vToDraw.sub(v);
drawSeries(vToDraw, exps, count - 1,clrTrunc );
}
}
Complex complexExp(Complex v, int times) {
if (times == 0) {
return new Complex(1, 1);
} else if ( times == 1) {
return new Complex( v.r*v.r - v.i*v.i, 2*v.r*v.i );
} else {
return complexExp( new Complex( v.r*v.r - v.i*v.i, 2*v.r*v.i ), times - 1 );
}
}
class Complex {
float r, i;
Complex() {
this.r = 0;
this.i = 0;
}
Complex(float r, float i) {
this.r = r;
this.i = i;
}
void add(Complex nv) {
this.r += nv.r;
this.i += nv.i;
}
void sub(Complex nv) {
this.r -= nv.r;
this.i -= nv.i;
}
}

I think you can make the code cleaner if you write a more complete Complex class.
int w = 800, h = 600;
int numTimes = 10, cSize = 5;
float xr = 3, yr = 3;
void setup() {
size(w,h);
noLoop();
}
void mousePressed() {
redraw();
}
void draw() {
background(255);
Complex v = new Complex(mouseX*(xr/w) - (xr/2), mouseY*(yr/h) - (yr/2));
Complex[] exps = new Complex[numTimes];
for (int i = 0; i < numTimes; i++) {
exps[i] = v.raisedTo(i);
print(exps[i]);
}
ellipse(w/2, h/2, cSize, cSize);
print(exps);
drawSerie(exps, numTimes);
}
void drawSerie(Complex[] exps, int total)
{
Complex partial = new Complex(0, 0);
drawPartial(exps, total -1, partial);
}
void drawFinal(Complex toDraw)
{
point(toDraw.r*(w/xr) + (w/2), toDraw.i*(h/xr) + h/2);
}
void drawPartial(Complex [] exps, int depth, Complex partial)
{
if (depth == -1)
{
drawFinal(partial);
return;
}
int nextDepth = depth -1;
drawPartial(exps, nextDepth, partial);
Complex element = exps[depth];
drawPartial(exps, nextDepth, partial.add(element));
drawPartial(exps, nextDepth, partial.sub(element));
}
class Complex {
float r, i;
Complex() {
this.r = 0;
this.i = 0;
}
Complex(float r, float i) {
this.r = r;
this.i = i;
}
Complex(Complex other)
{
this.r = other.r;
this.i = other.i;
}
Complex mult(Complex other)
{
return new Complex(this.r*other.r - this.i*other.i, this.r*other.i + this.i*other.r);
}
Complex add(Complex nv) {
return new Complex(this.r + nv.r, this.i + nv.i);
}
Complex sub(Complex nv) {
return new Complex(this.r - nv.r, this.i - nv.i);
}
Complex raisedTo(int n) {
if (n == 0) {
return new Complex(1, 0);
}
else if (n % 2 == 0)
{
return (this.mult(this)).raisedTo(n/2);
}
else
{
return this.mult(this.raisedTo(n - 1 ));
}
}
String toString()
{
return "real: " + this.r + " imaginary: " + this.i;
}
}
The computation of the series is not efficient but, I think, it is clear

Related

Threaded Terrain Generation 3d Bug Unity

So I have this weird bug in my terrain generation project
I have 2 methods that were supposed to fix offsets for different noise scales between chunks but for some reason when I implimented threading it stopped working in seemingly random areas. I'm 100% sure this worked before threading.
public struct GetMeshData : IJob
{
public ChunkData chunkData;
public NativeArray<float> noiseMap;
public MeshData meshData;
public void Execute()
{
for (int z = 0; z < chunkData.chunkSize + 1; z++)
{
for (int x = 0; x < chunkData.chunkSize + 1; x++)
{
noiseMap[z * (chunkData.chunkSize + 1) + x] = Noise.GetNoiseValue(chunkData, x, z);
}
}
MeshData temporaryMeshData = MeshGeneration.GenerateMesh(chunkData, noiseMap, meshData.triangles, meshData.vertices, meshData.uvs);
meshData = temporaryMeshData;
}
public GetMeshData(ChunkData chunkData, NativeArray<Vector3> vertices, NativeArray<Vector2> uvs, NativeArray<int> triangles, NativeArray<float> noiseMap)
{
this.chunkData = chunkData;
this.meshData = new MeshData(vertices, uvs, triangles);
this.noiseMap = noiseMap;
}
}
this is the job while this is my code to handle it
for (int i = 0; i < meshJob.Count; i++)
{
if (meshJob[i].IsCompleted)
{
meshJob[i].Complete();
TerrainChunk currentChunk = chunks[meshJobData[i].chunkData.chunkPosition.x,
meshJobData[i].chunkData.chunkPosition.y];
PostMeshGeneration(currentChunk, meshJobData[i].meshData);
toBeAdjusted.Add(currentChunk);
meshJobData[i].noiseMap.Dispose();
meshJobData[i].meshData.vertices.Dispose();
meshJobData[i].meshData.triangles.Dispose();
meshJobData[i].meshData.uvs.Dispose();
meshJob.RemoveAt(i);
meshJobData.RemoveAt(i);
}
}
this is what I do after the job is complete:
public void PostMeshGeneration(TerrainChunk chunk, MeshData meshData)
{
Mesh mesh = new Mesh();
mesh.vertices = meshData.vertices.ToArray();
mesh.triangles = meshData.triangles.ToArray();
mesh.uv = meshData.uvs.ToArray();
chunk.GetChunkGameObject().GetComponent<MeshFilter>().mesh = mesh;
ReadjustMeshCollider(chunk);
}
lastly this is trying to fix the scale offsets
if (toBeAdjusted.Count != 0 && meshJob.Count == 0 && meshJobData.Count == 0)
{
while (toBeAdjusted.Count > 0)
{
TerrainChunk currentChunk = toBeAdjusted[0];
Mesh mesh = currentChunk.GetChunkGameObject().GetComponent<MeshFilter>().mesh;
AdjustNoiseScaling(currentChunk);
FixCornerVerticesOffset(currentChunk);
mesh.UploadMeshData(false);
ApplyColorsToChunk(currentChunk, mesh.vertices);
ReadjustMeshCollider(currentChunk);
toBeAdjusted.RemoveAt(0);
}
}
if you need to see more code go to the github link https://github.com/htmhell69/TerrainGenerationUnity

Processing, simple "raytracing" engine "target VM failed to initialize"

I've been trying to fix this thing for a while now but it doesn't seem to work; "Could not run the sketch (Target VM failed to initialize)."
I'll post the full code down below.
In the draw(), there are three for loops.
for(int i = 0; i<objectAmount; i++) {
circles[i].drawObj();
}
The first one creates the circles, while the second nested ones take care of collision and drawing the lines;
for(int i = 0; i<rayAmount; i++) {
rays[i].update();
for(int j = 0; j<objectAmount; j++) {
rays[i].collide(circles[j]);
}
line(rays[i].xPos, rays[i].yPos, rays[i].xEnd, rays[i].yEnd);
}
the .collide takes point on the 'ray' and moves closer to the circle until it reaches some value, where it marks the line's end, which is then used by the line() function to draw it to the circle.
For some reason, when I implemented the .collide function, everything stopped working unless I set the amount of rays to one, in which case no rays would appear but the circle generation would follow along just fine.
int rayAmount = 45;
int angleCorrect = 360/rayAmount;
int objectAmount = 10;
Ray[] rays = new Ray[rayAmount];
Object[] circles = new Object[objectAmount];
void setup() {
size(600, 400, P2D);
for(int i = 0; i<rayAmount; i++) {
rays[i] = new Ray(i*angleCorrect);
}
for(int i = 0; i<objectAmount; i++) {
circles[i] = new Object(random(0, 600), random(0, 400), random(20, 100));
}
}
void draw() {
background(255);
stroke(100);
for(int i = 0; i<objectAmount; i++) {
circles[i].drawObj();
}
for(int i = 0; i<rayAmount; i++) {
rays[i].update();
for(int j = 0; j<objectAmount; j++) {
rays[i].collide(circles[j]);
}
line(rays[i].xPos, rays[i].yPos, rays[i].xEnd, rays[i].yEnd);
}
}
class Ray {
float xPos, yPos, Angle, xEnd, yEnd;
Ray(float angle) {
xPos = mouseX;
yPos = mouseY;
Angle = angle;
}
void update() {
xPos = mouseX;
yPos = mouseY;
//xEnd = xPos + 100 * cos(radians(Angle));
//yEnd = yPos + 100 * sin(radians(Angle));
}
void collide(Object other) {
float newXEnd = this.xEnd;
float newYEnd = this.yEnd;
float distToObject = sqrt(pow(other.xPos-this.xPos, 2) + pow(other.yPos-this.yPos, 2));
while(distToObject > 1) {
newXEnd = newXEnd + distToObject * cos(radians(Angle));
newYEnd = newYEnd + distToObject * sin(radians(Angle));
distToObject = sqrt(pow(other.xPos-newXEnd, 2) + pow(other.yPos-newYEnd, 2));
}
this.xEnd = newXEnd;
this.yEnd = newYEnd;
}
}
class Object {
float xPos, yPos, radius;
Object(float x, float y, float r) {
xPos = x;
yPos = y;
radius = r;
}
void drawObj() {
stroke(100);
circle(xPos, yPos, radius);
}
}

What might cause a sprite to stop directional movement when colliding in a 2-D game (the sprite still animates)?

!! This is not my code - I am using this to learn !! However, I do not understand what might cause the sprite to stop it's directional movement when colliding with the "STONE" object. The entire 2-D Game will run and the sprite works properly, but when I move close to the end of the screen or too close to the stone, I get stuck in place. I could not find an explanation I understood completely. I apologize in advance if this is a trivial question to anyone.
Basic Solid Tile Class:
public class BasicSolidTile extends BasicTile {
public BasicSolidTile(int id, int x, int y, int tileColour) {
super(id, x, y, tileColour);
this.solid = true;
}
}
Tile Class:
public abstract class Tile {
public static final Tile[] tiles = new Tile[256];
public static final Tile VOID = new BasicSolidTile(0, 0, 0, Colours.get(000, -1, -1, -1));
public static final Tile STONE = new BasicSolidTile(1, 1, 0, Colours.get(-1, 333, -1, -1));
public static final Tile GRASS = new BasicTile(2, 2, 0, Colours.get(-1, 131, 141, -1));
protected byte id;
protected boolean solid;
protected boolean emitter;
public Tile(int id, boolean isSolid, boolean isEmitter) {
this.id = (byte) id;
if (tiles[id] != null) {
throw new RuntimeException("Duplicate tile id on" + id);
}
this.solid = isSolid;
this.emitter = isEmitter;
tiles[id] = this;
}
public byte getId() {
return id;
}
public boolean isSolid() {
return solid;
}
public boolean isEmitter() {
return emitter;
}
public abstract void render(Screen screen, Level level, int x, int y);
}
Mob Class:
public abstract class Mob extends Entity {
protected String name;
protected int speed;
protected int numSteps = 0;
protected boolean isMoving;
protected int movingDir = 1;
protected int scale = 1;
public Mob(Level level, String name, int x, int y, int speed) {
super(level);
this.name = name;
this.x = x;
this.y = y;
this.speed = speed;
}
public void move(int xa, int ya) {
// you want to check if they are not zero
if (xa != 0 && ya != 0) {
move(xa, 0);
move(0, ya);
numSteps--;
return;
}
numSteps++;
if (!hasCollided(x, y)) {
if (ya < 0)
movingDir = 0;
if (ya > 0)
movingDir = 1;
if (xa < 0)
movingDir = 2;
if (xa > 0)
movingDir = 3;
x += xa * speed;
y += ya * speed;
}
}
public abstract boolean hasCollided(int xa, int ya);
protected boolean isSolidTile(int xa, int ya, int x, int y) {
if (level == null) {
return false;
}
Tile lastTile = level.getTile((this.x + x) >> 3, (this.y + y) >> 3);
Tile newTile = level.getTile((this.x + x + xa) >> 3, (this.y + y + ya) >> 3);
if (!lastTile.equals(newTile) && newTile.isSolid()) {
return true;
}
return false;
}
public String getName() {
return name;
}
}
Level Class:
public class Level {
// array of id's
private byte[] tiles;
public int width;
public int height;
public List<Entity> entities = new ArrayList<Entity>();
public Level(int width, int height) {
tiles = new byte[width * height];
this.width = width;
this.height = height;
this.generateLevel();
}
public void generateLevel() {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (x * y %10 < 7) {
tiles[x + y * width] = Tile.GRASS.getId();
} else {
tiles[x + y * width] = Tile.STONE.getId();
}
}
}
}
public void tick() {
// loop through all the vars if you dont need an index var
for (Entity e : entities) {
e.tick();
}
}
public void renderTiles(Screen screen, int xOffset, int yOffset) {
if (xOffset < 0)
xOffset = 0;
if (xOffset > ((width << 3) - screen.width))
xOffset = ((width << 3) - screen.width);
if (yOffset < 0)
yOffset = 0;
if (yOffset > ((height << 3) - screen.height))
yOffset = ((height << 3) - screen.height);
screen.setOffset(xOffset, yOffset);
for (int y = (yOffset >> 3); y < (yOffset + screen.height >> 3) + 1; y++) {
for (int x = (xOffset >> 3); x < (xOffset + screen.width >> 3) + 1; x++) {
getTile(x, y).render(screen, this, x << 3, y << 3);
}
}
}
public void renderEntities(Screen screen) {
for (Entity e : entities) {
e.render(screen);
}
}
public Tile getTile(int x, int y) {
if (0 > x || x >= width || 0 > y || y >= height)
return Tile.VOID;
return Tile.tiles[tiles[x + y * width]];
}
public void addEntity(Entity entity) {
this.entities.add(entity);
}
}
Player Class:
public class Player extends Mob {
private InputHandler input;
private int colour = Colours.get(-1, 111, 145, 543);
private int scale = 1;
public Player(Level level, int x, int y, InputHandler input) {
super(level, "Player", x, y, 1);
this.input = input;
}
public void tick() {
int xa = 0;
int ya = 0;
if (input.up.isPressed()) {
ya--;
}
if (input.down.isPressed()) {
ya++;
}
if (input.left.isPressed()) {
xa--;
}
if (input.right.isPressed()) {
xa++;
}
if (xa != 0 || ya != 0) {
move(xa, ya);
isMoving = true;
} else {
isMoving = false;
}
this.scale = 1;
}
public void render(Screen screen) {
int xTile = 0;
int yTile = 28;
int walkingSpeed = 4;
int flipTop = (numSteps >> walkingSpeed) & 1;
int flipBottom = (numSteps >> walkingSpeed) & 1;
if (movingDir == 1) {
xTile += 2;
} else if (movingDir > 1) {
xTile += 4 + ((numSteps >> walkingSpeed) & 1) * 2;
flipTop = (movingDir - 1) % 2;
}
int modifier = 8 * scale;
int xOffset = x - modifier / 2;
int yOffset = y - modifier / 2 - 4;
// upper body
screen.render(xOffset + (modifier * flipTop), yOffset, xTile + yTile * 32, colour, flipTop, scale);
screen.render(xOffset + modifier - (modifier * flipTop), yOffset, (xTile + 1) + yTile * 32, colour, flipTop, scale);
// lower body
screen.render(xOffset + (modifier * flipBottom), yOffset + modifier, xTile + (yTile + 1) * 32, colour, flipBottom, scale);
screen.render(xOffset + modifier - (modifier * flipBottom), yOffset + modifier, (xTile + 1) + (yTile + 1) * 32, colour, flipBottom,
scale);
}
public boolean hasCollided(int xa, int ya) {
int xMin = 0;
int xMax = 7;
int yMin = 3;
int yMax = 7;
for (int x = xMin; x < xMax; x++) {
if (isSolidTile(xa, ya, x, yMin)) {
return true;
}
}
for (int x = xMin; x < xMax; x++) {
if (isSolidTile(xa, ya, x, yMax)) {
return true;
}
}
for (int y = yMin; y < yMax; y++) {
if (isSolidTile(xa, ya, xMin, y)) {
return true;
}
}
for (int y = yMin; y < yMax; y++) {
if (isSolidTile(xa, ya, xMax, y)) {
return true;
}
}
return false;
}
}
Okay. It took me FOREVER, but it was a simple fix. All I had to do was change the "(x, y)" to "(xa, ya)"
if (!hasCollided(xa, ya)) {
if (ya < 0)
movingDir = 0;
if (ya > 0)
movingDir = 1;
if (xa < 0)
movingDir = 2;
if (xa > 0)
movingDir = 3;
x += xa * speed;
y += ya * speed;
}
}

How can I make start again after gameover?? (Processing)

I want to make this game in Processing.
When in 'Switch' those are displayed case0,1,2 in same time.
I don't know how to edit it.
and after case2(gameover), press key '1' to start again.
but I think it goes to case1 when gameover situation...
How can I edit it??
PImage work[] = new PImage[3];
float workSize[] = new float[3];
float workX[] = new float[3];
float workY[] = new float[3];
float workS[] = new float[3];
PImage handA, handB;
PFont font;
int level;
boolean gameover = false;
boolean selected[] = new boolean [3];
int salary = 0;
void setup(){
size(1000,800);
background(255);
imageMode(CENTER);
for (int i=0; i<3; i++) {
workX[i] = random(0, width);
workY[i] = random(0, height);
selected[i] = false;
workSize[i] = 120;
}
handA = loadImage("handA.png");
handB = loadImage("handB.png");
work[0] = loadImage("work0.png");
work[1] = loadImage("work1.png");
work[2] = loadImage("work2.png");
font = createFont("Gulim", 48);
textFont(font);
textAlign(CENTER, CENTER);
}
void draw(){
background(255);
if (mousePressed) {
cursor(handB, 0, 0);
} else {
cursor(handA, 0, 0);
}
switch (level) {
default: // press'1' to start game
fill(0);
text("1을 눌러 일 얻기", width/2, height/2);
if (key == '1') {
level = 1;
}
break;
case 1:
game();
if (gameover == true) {
level = 2;
}
break;
case 2: // press '1' to start again
fill(0);
text("퇴직금 : "+ salary + " + (비정규직으로 퇴직금 없음)", width/2, height/2-100);
text("일을 못해서 정리해고", width/2, height/2);
text("1을 눌러 다시 일 얻기", width/2, height/2+100);
if (key == '1') {
level = 1;
}
break;
}
}
void game() {
for (int i=0; i<3; i++) {
float clickedDist = dist(workX[i], workY[i], mouseX, mouseY);
if (clickedDist<workSize[i]/2 && mousePressed) {
workSize[i] = workSize[i] - 2;
} else {
workSize[i] = workSize[i] + 0.7;
}
if (workSize[i]<100) {
workSize[i] = 0;
}
if (workSize[i]>400) {
gameover = true;
}
if (workSize[i] == 0 && selected[i] == false) {
salary = salary + 50;
selected[i] = true;
workX[i] = random(0, width);
workY[i] = random(0, height);
selected[i] = false;
workSize[i] = 120;
}
if (salary > 150) {
workS[i] = workSize[i] + 0.5;
workSize[i] = workS[i];
}
if (abs(mouseX-workX[i]) < workSize[i]/2 && abs(mouseY-workY[i]) < workSize[i]/2) {
workX[i] += random(-5,5);
workY[i] += random(-5,5);
}
image(work[i], workX[i], workY[i], workSize[i], workSize[i]);
pushMatrix();
fill(0);
textSize(48);
text("봉급 : "+ salary, textWidth("salary"), (textAscent()+textDescent()/2));
popMatrix();
}
}
All you have to do is reset any variables that store the state of your game, such as your level variable. Something like this:
void keyPressed(){
if(gameover && key == '1'){
gameover = false;
level = 1;
}
}

j2me program to create a GRID menu?

I want to create a list of operation's in a grid view. For example visit this URL.
http://cdn-static.cnet.co.uk/i/product_media/40000186/nokia1616_01.jpg
You can look at this question or this page(and use LWUIT or CustomItems) or extend "canvas".In this way you need to two pictures for every operation in grid view.One for normal state and another for highlighted.Here is a simple canvas that represents 4 operations in 2*2 grid:
public class GridCanvas extends Canvas {
int highlightedRow = 0;
int highlightedColumn = 0;
Image[][] normalImageMat;
Image[][] highlightedImageMat;
Image[][] imageMat;
int gridColumnNo;
int gridRowNo;
/**
* constructor
*/
public GridCanvas() {
gridColumnNo = 2;
gridRowNo = 2;
normalImageMat = new Image[gridRowNo][gridColumnNo];
highlightedImageMat = new Image[gridRowNo][gridColumnNo];
imageMat = new Image[gridRowNo][gridColumnNo];
try {
for (int i = 0; i < gridRowNo; i++) {
for (int j = 0; j < gridColumnNo; j++) {
normalImageMat[i][j] = Image.createImage("/hello/normalImage" + i + j + ".png");
}
}
for (int i = 0; i < gridRowNo; i++) {
for (int j = 0; j < gridColumnNo; j++) {
highlightedImageMat[i][j] = Image.createImage("/hello/highlightedImage" + i + j + ".png");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* paint
*/
public void paint(Graphics g) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, getWidth(), getHeight());
for (int i = 0; i < gridRowNo; i++) {
System.arraycopy(normalImageMat[i], 0, imageMat[i], 0, 2);
}
imageMat[highlightedRow][highlightedColumn] = highlightedImageMat[highlightedRow][highlightedColumn];
int width = 0;
int height = 0;
for (int i = 0; i < gridRowNo; i++) {
for (int j = 0; j < gridColumnNo; j++) {
g.drawImage(imageMat[i][j], width, height, 0);
width = width + imageMat[i][j].getWidth();
}
width = 0;
height = height + imageMat[0][0].getHeight();
}
}
/**
* Called when a key is pressed.
*/
protected void keyPressed(int keyCode) {
int gameAction = this.getGameAction(keyCode);
if (gameAction == RIGHT) {
highlightedColumn = Math.min(highlightedColumn + 1, gridColumnNo - 1);
} else if (gameAction == LEFT) {
highlightedColumn = Math.max(highlightedColumn - 1, 0);
} else if (gameAction == UP) {
highlightedRow = Math.max(0, highlightedRow - 1);
} else if (gameAction == DOWN) {
highlightedRow = Math.min(gridRowNo - 1, highlightedRow + 1);
}
repaint();
}
}
In real samples you would to detect gridColumnNo and gridRowNo due to screen and your icons dimensions.
If you can not go with LWUIT (license, library size, etc) and do not want to leave the screen rendering to LCDUI (CustomItem), you should extend Canvas.
I have shared code for an adaptive grid at http://smallandadaptive.blogspot.com.br/2010/12/touch-menu.html Feel free to use it.
At this sample all items are Strings, but you can change the TouchItem to draw Images instead.

Resources