bool nn_fuzzy_set::normal_set() { reset_position(); while (!end_of_set()) { if(get_membership() == 1) return true; next_member(); } return false; }
nn_fuzzy_set nn_fuzzy_set::strong_alpha_cut(double alpha) { nn_fuzzy_set result; reset_position(); while (!end_of_set()) { if(get_membership() > alpha) result.add_new(get_member(),get_membership()); next_member(); } return result; }
nn_fuzzy_set nn_fuzzy_set::crossover() { nn_fuzzy_set result; reset_position(); while (!end_of_set()) { if(get_membership() == 0.5) result.add_new(get_member(),get_membership()); next_member(); } return result; }
nn_fuzzy_set nn_fuzzy_set::support() { nn_fuzzy_set result; reset_position(); while (!end_of_set()) { if(get_membership() > 0) result.add_new(get_member(),get_membership()); next_member(); } return result; }
bool nn_fuzzy_set::complement(int type = NN_COMPLEMENT_NORMAL, int parameter = 1) { switch (type) { case NN_COMPLEMENT_NORMAL: // perform complement by the normal complement method like in crisp sets reset_position(); while(!end_of_set()) { set_membership(1 - get_membership()); next_member(); } return true; case NN_COMPLEMENT_SUGENOCLASS: // perform complement by the sugeno class of operators reset_position(); while(!end_of_set()) { set_membership((1 - get_membership()) / (1 + (parameter * get_membership()))); next_member(); } return true; default: return NULL; } }
/** * @brief 初期化 * @param wheelRadius 車輪の直径 * @param wheels_distance 車輪間の距離 * @param px 初期位置X * @param py 初期位置Y * @param a 初期姿勢 * @return true */ bool controlEV3::init(float wheelRadius, float wheelDistance, float px, float py, float a) { set_param(wheelRadius, wheelDistance); reset_position(px, py, a); if(right_touch_sensor)delete right_touch_sensor; if(left_touch_sensor)delete left_touch_sensor; if(color_sensor)delete color_sensor; if(ultrasonic_sensor)delete ultrasonic_sensor; if(gyro_sensor)delete gyro_sensor; if(left_large_motor)delete left_large_motor; if(right_large_motor)delete right_large_motor; if(medium_motor)delete medium_motor; right_touch_sensor = new ev3dev::touch_sensor(RIGHT_TOUCH_SENSOR_ADDRESS); if(!right_touch_sensor->connected()) { delete right_touch_sensor; right_touch_sensor = new ev3dev::touch_sensor(); } left_touch_sensor = new ev3dev::touch_sensor(LEFT_TOUCH_SENSOR_ADDRESS); color_sensor = new ev3dev::color_sensor(); ultrasonic_sensor = new ev3dev::ultrasonic_sensor(); gyro_sensor = new ev3dev::gyro_sensor(); left_large_motor = new ev3dev::large_motor(LEFT_LARGE_MOTOR_ADDRESS); if(left_large_motor->connected()) { left_large_motor->set_stop_command(ev3dev::motor::stop_command_hold); } right_large_motor = new ev3dev::large_motor(RIGHT_LARGE_MOTOR_ADDRESS); if(right_large_motor->connected()) { right_large_motor->set_stop_command(ev3dev::motor::stop_command_hold); } medium_motor = new ev3dev::medium_motor(); if(medium_motor->connected()) { medium_motor->set_stop_command(ev3dev::motor::stop_command_hold); } return true; }
/* * Reads keyboard input and updates scene variables. * 'w' moves forward, 's' moves back * 'a' strafes left, 'd' strafes right * 'r' resets the view * 'f' Sets movement to free, 'p' sets movement to person */ void input_update () { float distance = 60.0f * getTimeStep(); static float walkTheta = 0; vect3_t old_position, boundingBox = {1,1,1}; VectorCopy(camera.position, old_position); // walk motion if (keys_down[SDLK_w] || keys_down[SDLK_s]) { walkTheta -= getTimeStep(); walkHeight = WALK_POSITION_SCALE*sin(walkTheta * WALK_TIME_SCALE); } // WASD movement if(keys_down[SDLK_w]) { camera_translateForward(-1 * distance); } if(keys_down[SDLK_s]) { camera_translateForward(distance); } if(keys_down[SDLK_a]) camera_translateStrafe(-1 * distance); if(keys_down[SDLK_d]) camera_translateStrafe(distance); if (world_testCollision(boundingBox)) VectorCopy(old_position, camera.position); if(keys_down[SDLK_z]) camera.position[_X] += 1; if(keys_down[SDLK_x]) camera.position[_X] -= 1; if(keys_down[SDLK_c]) camera.position[_Y] += 1; if(keys_down[SDLK_v]) camera.position[_Y] -= 1; if(keys_down[SDLK_b]) camera.position[_Z] += 1; if(keys_down[SDLK_n]) camera.position[_Z] -= 1; // r for reset if(keys_down[SDLK_r]){ reset_position(); } // Set movement to free or person if (keys_down[SDLK_f]) free_move = 1; else if (keys_down[SDLK_p]) free_move = 0; }
/* * Load data points and labels that are in different files */ void DataSet::load(const string& x_filename, const string& y_filename, bool add_points) { x_filename_ = x_filename; y_filename_ = y_filename; add_points_ = add_points; reset_position(); if (load_iterative_) { if (add_points) { cout << "[ERROR] - DataSet.load: option 'add' and 'load_iterative' is not possible" << endl; exit(EXIT_FAILURE); } x_file_.close(); y_file_.close(); load_dataset_iteratively(x_filename, y_filename); open_position_file(x_filename); } else { if (add_points) sample_pos_ = 0; load_complete_dataset(x_filename, y_filename); } }
void dt_config::setup(){ width = 250; height = 20; int color = 110; { status.setDefaultWidth(width); status.setDefaultHeight(height); status.setDefaultTextColor(color); status.setup(); status.setName("status"); status.add(fps.setup("fps", "")); status.add(sleep_microsec.setup("/sleep_microsec", "")); status.add(master_clock_out_resolution.setup("/master_clock_out_resolution", "")); status.add(circle_num.setup("all circle num", "")); status.add(noteOn_num.setup("noteOn circle num", "")); status.add(param_num.setup("param circle num", "")); status.add(output_num.setup("output circle num", "")); } { osc.setDefaultWidth(width); osc.setDefaultHeight(height); osc.setDefaultTextColor(color); osc.setup(); osc.setName("osc"); osc.add(osc_out_ch_max.setup("/osc_out_ch_max", ofToString(DT_OSC_OUT_CH_MAX))); osc.add(osc_out_ch_min.setup("/osc_out_ch_min", ofToString(DT_OSC_OUT_CH_MIN))); osc.add(osc_out_address.setup("/osc_out_address", ofToString(DT_OSC_OUT_ADDRESS))); osc.add(osc_out_port.setup("/osc_out_port", ofToString(DT_OSC_OUT_PORT))); osc.add(osc_in_port.setup("/osc_in_port", ofToString(DT_OSC_IN_PORT))); } { generative_rhythm.setDefaultWidth(width); generative_rhythm.setDefaultHeight(height); generative_rhythm.setDefaultTextColor(color); generative_rhythm.setup(); generative_rhythm.setName("generative_rhythm"); generative_rhythm.add(play_gen_rhythm.setup("/play_gen_rhythm", toOnOff(DT_PLAY_GEN_RHYTHM))); generative_rhythm.add(gen_rhythm_rate.setup("/gen_rhythm_rate", ofToString(DT_GEN_RHYTHM_RATE)+"%")); generative_rhythm.add(rhythm_shape_slot_min.setup("/rhythm_shape_slot_min", ofToString(DT_RHYTHM_SHAPE_SLOT_MIN))); generative_rhythm.add(rhythm_shape_slot_max.setup("/rhythm_shape_slot_max", ofToString(DT_RHYTHM_SHAPE_SLOT_MAX))); generative_rhythm.add(beat_resolution.setup("/beat_resolution", ofToString(DT_BEAT_RESOLUTION))); generative_rhythm.add(beat_speed_max.setup("/beat_speed_max", ofToString(DT_BEAT_SPEED_MAX))); generative_rhythm.add(connection_num_input_max.setup("/connection_num_input_max", ofToString(DT_CONNECTION_NUM_INPUT_MAX))); generative_rhythm.add(connection_num_output_max.setup("/connection_num_output_max", ofToString(DT_CONNECTION_NUM_OUTPUT_MAX))); } { buffered_rhythm.setDefaultWidth(width); buffered_rhythm.setDefaultHeight(height); buffered_rhythm.setDefaultTextColor(color); buffered_rhythm.setup(); buffered_rhythm.setName("buffered_rhythm"); buffered_rhythm.add(play_buffered_rhythm.setup("/play_buffered_rhythm", toOnOff(DT_PLAY_BUFFERED_RHYTHM))); buffered_rhythm.add(buffered_rhythm_rate.setup("/buffered_rhythm_rate", ofToString(DT_BUFFERED_RHYTHM_RATE)+"%")); buffered_rhythm.add(buffered_rhythm_indicator.setup("/buffered_rhythm_indicator", ofToString(DT_BUFFERED_RHYTHM_INDICATOR))); buffered_rhythm.add(buffered_rhythm_loop_start.setup("/buffered_rhythm_loop_start", ofToString(DT_BUFFERED_RHYTHM_LOOP_START))); buffered_rhythm.add(buffered_rhythm_loop_end.setup("/buffered_rhythm_loop_end", ofToString(DT_BUFFERED_RHYTHM_LOOP_END))); buffered_rhythm.add(show_buffered_rhythm.setup("/show_buffered_rhythm", toOnOff(DT_SHOW_BUFFERED_RHYTHM))); } reset_position(); }
nn_fuzzy_set nn_fuzzy_set::t_norm(nn_fuzzy_set op2,int type = NN_TNORM_MINIMUM) { nn_fuzzy_set result; reset_position(); op2.reset_position(); if (nn_size() != op2.nn_size()) { nn_incompatibleFuzzySetsException ex; throw ex; } switch (type) { case NN_TNORM_MINIMUM: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } if (get_membership() > op2.get_membership()) { result.add_new(get_member(), op2.get_membership()); } else { result.add_new(get_member(), get_membership()); } next_member(); op2.next_member(); } break; case NN_TNORM_PRODUCT: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } result.add_new(get_member(), get_membership() * op2.get_membership()); next_member(); op2.next_member(); } break; case NN_TNORM_EINSTEIN_PRODUCT: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } result.add_new(get_member(), (get_membership() * op2.get_membership()) / (2 - ((get_membership() + op2.get_membership()) - get_membership() * op2.get_membership()))); next_member(); op2.next_member(); } break; case NN_TNORM_DRASTIC_PRODUCT: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } if (op2.get_membership() == 1) { result.add_new(get_member(), get_membership()); } else if (get_membership() == 1) { result.add_new(get_member(), op2.get_membership()); } else { result.add_new(get_member(), 0.0); } next_member(); op2.next_member(); } break; default: break; } return result; }
nn_fuzzy_set nn_fuzzy_set::s_norm(nn_fuzzy_set op2,int type = NN_SNORM_MAXIMUM) { nn_fuzzy_set result; reset_position(); op2.reset_position(); if (nn_size() != op2.nn_size()) { nn_incompatibleFuzzySetsException ex; throw ex; } switch (type) { case NN_SNORM_MAXIMUM: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } if (get_membership() < op2.get_membership()) { result.add_new(get_member(), op2.get_membership()); } else { result.add_new(get_member(), get_membership()); } next_member(); op2.next_member(); } break; case NN_SNORM_SUM: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } result.add_new(get_member(), get_membership() + op2.get_membership() - (get_membership() * op2.get_membership())); next_member(); op2.next_member(); } break; case NN_SNORM_EINSTEIN_SUM: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } result.add_new(get_member(), get_membership() + op2.get_membership() / (1 + (get_membership() * op2.get_membership()))); next_member(); op2.next_member(); } break; case NN_SNORM_DRASTIC_SUM: while (!end_of_set()) { if (get_member() != op2.get_member()) { nn_incompatibleFuzzySetsException ex; throw ex; } if (op2.get_membership() == 0) { result.add_new(get_member(), get_membership()); } else if (get_membership() == 0) { result.add_new(get_member(), op2.get_membership()); } else { result.add_new(get_member(), 1.0); } next_member(); op2.next_member(); } break; default: break; } return result; }
// Draw the item list window // int List_Window::draw(window_info *win) { Vars::lists()->check_and_timed_save(false); // if resizing wait until we stop if (win->resized) resizing = true; // once we stop, snap the window size to fix nicely else if (resizing) { calc_num_show_names(win->len_y); resizing = false; resize_window (win->window_id, get_size_x(), get_size_y()); } // check if we need to change the number of grid rows shown int new_num_grid_rows = min_grid_rows(); if (Vars::lists()->valid_active_list()) new_num_grid_rows = std::max(static_cast<size_t>(new_num_grid_rows), (Vars::lists()->get_list().get_num_items() +5) / 6); if (num_grid_rows != new_num_grid_rows) { num_grid_rows = new_num_grid_rows; resized_name_panel(win); } // if the left/right position flag has changed, restore the window to its default location if (last_items_list_on_left != items_list_on_left) { if (last_items_list_on_left != -1) reset_position(); last_items_list_on_left = items_list_on_left; } glEnable(GL_TEXTURE_2D); // draw the images if (Vars::lists()->valid_active_list()) { glColor3f(1.0f,1.0f,1.0f); for(size_t i=0; i<Vars::lists()->get_list().get_num_items() && i<static_cast<size_t>(6*num_grid_rows); i++) { int x_start, y_start; x_start = get_grid_size() * (i%6) + 1; y_start = get_grid_size() * (i/6); draw_item(Vars::lists()->get_list().get_image_id(i), x_start, y_start, get_grid_size()); } } size_t help_lines_shown = 0; if (desc_str) { show_help(desc_str, 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++)); desc_str = 0; } // Display any name search text if (strlen(filter)) { if (SDL_GetTicks() > (last_key_time+5000)) { filter[0] = '\0'; last_key_time = 0; } else { std::string tmp = std::string(item_list_find_str) + std::string("[") + std::string(filter) + std::string("]"); show_help(tmp.c_str(), 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++)); } } // draw mouse over window help text if (show_help_text) { if (!resizing) for (size_t i=0; i<help_str.size(); ++i) show_help(help_str[i], 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++)); help_str.clear(); } glDisable(GL_TEXTURE_2D); // draw the item grid glColor3f(newcol_r, newcol_g, newcol_b); rendergrid(6, num_grid_rows, 0, 0, get_grid_size(), get_grid_size()); // if an object is selected, draw a green grid around it if (Vars::lists()->valid_active_list() && (quantities.selected == ITEM_EDIT_QUANT) && (selected_item_number < Vars::lists()->get_list().get_num_items())) { int x_start = selected_item_number%6 * get_grid_size(); int y_start = static_cast<int>(selected_item_number/6) * get_grid_size(); if ((SDL_GetTicks() - pickup_fail_time) < 250) glColor3f(0.8f,0.2f,0.2f); else glColor3f(0.0f, 1.0f, 0.3f); rendergrid(1, 1, x_start, y_start, get_grid_size(), get_grid_size()); rendergrid(1, 1, x_start-1, y_start-1, get_grid_size()+2, get_grid_size()+2); } glEnable(GL_TEXTURE_2D); // draw the quantities over everything else so they always show if (Vars::lists()->valid_active_list()) { glColor3f(1.0f,1.0f,1.0f); char str[80]; for(size_t i=0; i<Vars::lists()->get_list().get_num_items() && i<static_cast<size_t>(6*num_grid_rows); i++) { int x_start, y_start, y_end; x_start = get_grid_size() * (i%6) + 1; y_start = get_grid_size() * (i/6); y_end = y_start + get_grid_size() - 1; safe_snprintf(str, sizeof(str), "%i", Vars::lists()->get_list().get_quantity(i)); draw_string_small_shadowed(x_start, (i&1)?(y_end-15):(y_end-27), (unsigned char*)str, 1,1.0f,1.0f,1.0f, 0.0f, 0.0f, 0.0f); } } // Drawn the new list button (+) with highlight when mouse over if (mouse_over_add_button) glColor3f(0.99f,0.77f,0.55f); else glColor3f(newcol_r, newcol_g, newcol_b); draw_string_zoomed(add_button_x, add_button_y, (unsigned const char*)"+", 1, 2.0); // draw the item list names glColor3f(1.0f,1.0f,1.0f); int pos_y = get_grid_size()*num_grid_rows + get_list_gap(); int num_shown = 0; const int top_entry = vscrollbar_get_pos (win_id, names_scroll_id); const std::vector<List> lists = Vars::lists()->get_lists(); const int hl_width = static_cast<int>(win->len_x-ELW_BOX_SIZE-3); const int hl_height = static_cast<int>(names_list_height + get_list_gap()); const size_t disp_chars = static_cast<size_t>((win->len_x-ELW_BOX_SIZE-2*get_list_gap()) / SMALL_FONT_X_LEN); for (size_t i = top_entry; i<lists.size() && num_shown<num_show_names_list; ++i) { if (i==Vars::lists()->get_active()) draw_highlight(1, static_cast<int>(pos_y-get_list_gap()/2), hl_width, hl_height, 1); else if (i==name_under_mouse) draw_highlight(1, static_cast<int>(pos_y-get_list_gap()/2), hl_width, hl_height, 0); glColor3f(1.0f,1.0f,1.0f); if (lists[i].get_name().size() > disp_chars) { std::string todisp = lists[i].get_name().substr(0,disp_chars); draw_string_small(get_list_gap(), pos_y, reinterpret_cast<const unsigned char*>(todisp.c_str()), 1); if (i==name_under_mouse) show_help(lists[i].get_name().c_str(), 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown)); } else draw_string_small(get_list_gap(), pos_y, reinterpret_cast<const unsigned char*>(lists[i].get_name().c_str()), 1); pos_y += static_cast<int>(names_list_height + get_list_gap()); num_shown++; } if (clicked && (name_under_mouse < lists.size())) { do_click_sound(); Vars::lists()->set_active(name_under_mouse); } if (clicked && mouse_over_add_button) { do_click_sound(); new_or_rename_list(true); } name_under_mouse = static_cast<size_t>(-1); mouse_over_add_button = clicked = false; #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }