Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ocean.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- ocean::ocean() {
- coords ocean_c = {.0, .0, .0, .0};
- oc_speed = 0;
- box = 10;
- }
- ocean::ocean(coords oc_input, int box_in, float oc_speed_in) {
- ocean_c = oc_input;
- oc_speed = oc_speed_in;
- box = box_in;
- }
- coords ocean::coords_to_unit(coords temp) {
- float lenght;
- lenght = sqrt((temp.x * temp.x) + (temp.y * temp.y) + (temp.z * temp.z));
- if(lenght < 0.0) {
- temp.x = temp.x/lenght;
- temp.y = temp.y/lenght;
- temp.z = temp.z/lenght;
- temp.lenght = lenght;
- }
- return temp;
- }
- void ocean::change_ocean(coords temp) {
- ocean_c = coords_to_unit(temp);
- }
- void ocean::change_ocean_speed(float oc_speed_in) {
- oc_speed = oc_speed_in;
- }
- fish::fish() {
- coords ocean_c = {.0, .0, .0, .0};
- oc_speed = 0;
- box = 10;
- coords fish_c = {.0, .0, .0, .0};
- coords fish_direction = {.0, .0, .0, .0};
- fish_speed = 0;
- }
- fish::fish(coords oc_input, int box_in, float oc_speed_in, coords fish_input, coords fish_directions_input, int fish_speed_in) {
- ocean_c = oc_input;
- oc_speed = oc_speed_in;
- box = box_in;
- fish_c = fish_input;
- fish_direction = fish_directions_input;
- fish_speed = fish_speed_in;
- ocean_c = coords_to_unit(ocean_c);
- fish_direction = coords_to_unit(fish_direction);
- }
- void fish::show_coordinates() {
- cout << "Fish coordinates: " << fish_c.x << ", " << fish_c.y << ", " << fish_c.z << endl;
- }
- void fish::move(float time) {
- coords ocean_temp;
- coords fish_temp;
- ocean_temp.x = oc_speed * ocean_c.x;
- ocean_temp.y = oc_speed * ocean_c.y;
- ocean_temp.z = oc_speed * ocean_c.z;
- fish_temp.x = fish_speed * fish_direction.x;
- fish_temp.y = fish_speed * fish_direction.y;
- fish_temp.z = fish_speed * fish_direction.z;
- fish_c.x = (time * (ocean_temp.x + fish_temp.x)) + fish_c.x;
- fish_c.y = (time * (ocean_temp.y + fish_temp.y)) + fish_c.y;
- fish_c.z = (time * (ocean_temp.z + fish_temp.z)) + fish_c.z;
- }
- void fish::change_fish(coords temp) {
- fish_direction = coords_to_unit(temp);
- }
- void fish::change_fish_speed(int fish_speed_in) {
- fish_speed = fish_speed_in;
- }
- ostream &operator<<(ostream& s, fish& d) {
- s << "===========FISH===========" << endl << "Coordinates: " << d.fish_c.x << ", " << d.fish_c.y << ", " << d.fish_c.z << endl << "Direction: "
- << d.fish_direction.x << ", " << d.fish_direction.y << ", " << d.fish_direction.z << endl << "Speed: " << d.fish_speed << endl << "==========================" << endl << endl;
- return s;
- }
Add Comment
Please, Sign In to add comment