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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
//.cpp////////////////////////////
#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <cstdlib>
//#include<ctime>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
#include "Vec2.h"
#include "Circle.h"
#include "fArray.h"
typedef unsigned short int usi;
typedef signed short int ssi;
typedef unsigned long int uli;
typedef signed long int sli;
int main(){
Circle<int,int> test(2,1,1);
fArray<int> test3;
test3 = test.testFnc();
//Circle<int,int> test2 = test3.testFnc();
//circum = test.genCircum<long double>(8);
}
/////////////////////////////////////////////////////
relevent function is last
//circle.h///////////////////////////////////////////
#pragma once
#include "fArray.h"
#include "Vec2.h"
typedef unsigned short int usi;
typedef signed short int ssi;
typedef unsigned long int uli;
typedef signed long int sli;
template <class cType,class rType>
class Circle
{
Vec2<cType> center;
rType rad;
public:
Circle(void){
center.setV(0,0);
rad = 0;
}
Circle(Vec2<cType> ncenter,rType nrad){
center = ncenter;
rad = nrad;
}
Circle(cType ncx,cType ncy,rType nrad){
center.setV(ncx,ncy);
rad = nrad;
}
void operator+= (Vec2<cType> pc){
center += pc;
}
void operator+= (rType pr){
rad += pr;
}
void operator-= (Vec2<cType> pc){
center -= pc;
}
void operator-= (rType pr){
rad -= pr;
}
void operator= (Vec2<cType> nc){
center = nc;
}
void operator= (Circle<cType,rType> nc){
center = nc.getCenter();
rad = nc.getRad();
}
Vec2<cType> getCenter(){
return center;
}
rType getRad(){
return rad;
}
template <class nType>
void convertC(){
center.convert<nType>();
}
template <class nType>
void convertR(){
rad = (nType) rad;
}
template <class nType,class nType2>
void convertCR(){
convertC<nType1>();
convertR<nType2>();
}
void coutC(){
cout<<"Circle center: x = "<<center.getX()<<"\ty = "<<center.getY()<<"\tradius "<<rad<<endl;
}
template <class vType>
fArray<Vec2<vType>> genCircum(usi split){
fArray<Vec2<vType>> tempA;
for(usi i = 0;i < split;i++){
Vec2<vType> temp;
//Vec2<cType> add;
temp.setD(rad,360*i/split);
//add = center;
//add.convert<vType>();
//temp += add;
tempA.addEnd(temp);
}
return tempA;
}
fArray<int> testFnc(){
fArray<int> temp;
return temp;
}
};
/////////////////////////////////////////////////////////////
//fArray.h////////////////////////////////////////////////
#pragma once
typedef signed long int sli;
template <class mType>
class fArray
{
sli length;
mType *tempData;
mType *data;
public:
fArray(void){
length = 0;
data = new mType[length];
}
~fArray(void){
delete [] data;
}
mType getValue(sli i){
return data[i];
}
void add(mType value,sli index){
length++;
tempData = new mType[length];
for(sli i=0;i<index;i++){
tempData[i] = data[i];
}
for(sli i=index;i<length-1;i++){
tempData[i+1] = data[i];
}
tempData[index] = value;
delete [] data;
data = new mType[length];
for(sli i = 0;i < length;i++){
data[i] = tempData[i];
}
delete [] tempData;
}
void addEnd(mType value){
add(value,length);
}
sli getLength(){
return length;
}
void operator= (fArray<mType> na){
delete [] data;
length = na.getLength();
data = new mType[length];
for(sli i =0;i<length-10;i++){
data[i] = na.getValue(i);
}
}
};
///////////////////////////////////////////////////////////
|