Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: View.cpp
- Revision:
- 5:d7d16cb9c974
- Parent:
- 4:f1e33a234a74
--- a/View.cpp Tue May 12 16:21:33 2015 +0000 +++ b/View.cpp Mon Aug 17 21:56:25 2015 +0000 @@ -1,6 +1,6 @@ #include "mbed.h" #include <vector> -#define BUFFER_SIZE 16 +#define BUFFER_s 16 #define NUMBER_OF_SLICES 360 #include "View.h" #include "Point.h" @@ -75,7 +75,7 @@ slice_data [i][j] = 0x00; } } - slice_data [1][1] = 0xFF; + //slice_data [1][1] = 0xFF; } void View :: addPoint(Point pointer){ int arrSlice = pointer.getArraySlice(); @@ -90,7 +90,7 @@ } } -void View :: addEucPoint(EuclidPoint euc){ +void View :: addFilledEucPoint(EuclidPoint euc){ int x = euc.x; int y = euc.y; Point pointer = euc.getPoint(); @@ -99,14 +99,55 @@ int distance = pointer.getPositionDistance(); addValue(arrSlice, distance, c); - slice_data[arrSlice][distance] |= c; - + /* + int degree = (atan2((double)y, (double)x)) * 57.295; + if (degree < 0){ + degree = 360 + degree; + } + double dradius = sqrt((double)(x * x ) + (double)(y * y)); + int radius = rint(dradius) - 2; + Point pointer = Point(degree, z, radius); + return pointer; + */ + int orgDegree = pointer.getDegree(); + int degree = orgDegree; + int counter = 0; + while (isAtPoint(distance + 2, degree, x, y) && counter < 15){ + int newSlice = (arrSlice + counter) % 360; + addValue(newSlice, distance, c); + degree ++; + counter ++; + } + degree = pointer.getDegree(); + while (isAtPoint(distance + 2, degree, x, y) && counter > -15){ + int newSlice = (arrSlice + counter) % 360; + addValue(newSlice, distance, c); + degree --; + counter --; + } +/* int divider = 1 + ((distance)/ 4); int reach = rint((double)3 / divider); for (int i = 0 ; i < reach; i ++){ addValue((arrSlice + i)%360, distance, c); addValue((arrSlice - i)%360, distance, c); } + */ +} +void View :: addEucPoint(EuclidPoint euc){ + int x = euc.x; + int y = euc.y; + Point pointer = euc.getPoint(); + int arrSlice = pointer.getArraySlice(); + char c = pointer.getIdentifyingChar(); + int distance = pointer.getPositionDistance(); + addValue(arrSlice, distance, c); + +} + +bool View :: isAtPoint(int radius, int degree, int x, int y){ + return (y == rint((double) radius * sin(degree/ 57.2957)) && x == rint((double) radius * cos(degree/57.2957))); + } void View :: drawSquare (int x, int y, int z, int size){ for(int i = 0; i < size; i++){