Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double add_physics_vector(vector<double> v1, vector<double> v2)
- {
- double horizontal_1 = v1[1] * cos(v1[0]);
- double vertical_1 = v1[1] * sin(v1[0]);
- double horizontal_2 = v2[1] * cos(v2[0]);
- double vertical_2 = v2[1] * sin(v2[0]);
- double horizontal_total = horizontal_1 + horizontal_2;
- double vertical_total = vertical_1 + vertical_2;
- double final_magnitude = sqrt(pow(horizontal_total, 2) + pow(vertical_total, 2));
- double final_direction = atan2(vertical_total, horizontal_total);
- double final_set[2] = {final_direction, final_magnitude};
- return final_set;
- }
- error: cannot convert ‘double*’ to ‘double’ in return
- warning: control reaches end of non-void function [-Wreturn-type]
- vector<double> final_set = {final_direction, final_magnitude};
- return final_set;
- vector<double> add_physics_vector(vector<double> v1, vector<double> v2);
- pair<double, double> add_physics_vector(vector<double> v1, vector<double> v2)
- {
- // ...as before
- return make_pair(final_direction, final_magitude);
- }
- double * make_array()
- {
- double * array = malloc(sizeof(double) * 2);
- if (array == NULL) { /* .. error handling */ }
- return array;
- }
- struct Vector
- {
- double direction;
- double magnitude;
- }
- Vector make_vector()
- {
- vector = (Vector){ 1, 2 };
- return vector;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement