language-agnostic

Formula for controlling the movement of a tank-like vehicle?

旧城冷巷雨未停 提交于 2019-12-19 08:12:29
问题 Anyone know the formula used to control the movement of a simple tank-like vehicle? To 'steer' it, you need to alter the force applied the left and right "wheels". Eg. 1 unit of force on both wheels makes it go forward. -1 units of force on both wheels makes it go backwards. Apply more force to one wheel than the other and it turns. How would you calculate the amount of force needed on both wheels to turn the tank a certain number of degrees either way? Or am I thinking about this in the

Formula for controlling the movement of a tank-like vehicle?

久未见 提交于 2019-12-19 08:12:11
问题 Anyone know the formula used to control the movement of a simple tank-like vehicle? To 'steer' it, you need to alter the force applied the left and right "wheels". Eg. 1 unit of force on both wheels makes it go forward. -1 units of force on both wheels makes it go backwards. Apply more force to one wheel than the other and it turns. How would you calculate the amount of force needed on both wheels to turn the tank a certain number of degrees either way? Or am I thinking about this in the

What is the optimal StringBuffer initial capacity for inputs with drastically varying lengths?

江枫思渺然 提交于 2019-12-19 06:56:51
问题 Good afternoon all, I'm using a java.lang.StringBuilder to store some characters. I have no idea how many characters I'm going to store in advance, except that: 60% of the time, it is only (exactly) 7 characters 39% of the time, it is (roughly) 3500 characters 1% of the time, it is roughly 20k characters How do we go about calculating the optimal initial buffer length that should be used? Currently I'm using new java.lang.StringBuilder(4000) but that's just because I was too lazy to think

The opposite of Hungarian Notation?

北战南征 提交于 2019-12-19 06:05:23
问题 Most programmers know of a thing called 'Hungarian Notation', each variable has a nice prefix to denote its data type, i.e. bIsExciting = false; // Boolean strName = "Gonzo"; // String iNumber = 10; // Integer While this style of notation has fallen out of favor, I am seeing (at work, internet, etc.) a lot of data type indicators added as a ' suffix ' to variable names, i.e. NameStr = "Gonzo"; // String NumberInt = 10; // Integer MyRideBike = new Bike(); // Bicycle Is there a name for this,

The opposite of Hungarian Notation?

孤街浪徒 提交于 2019-12-19 06:05:06
问题 Most programmers know of a thing called 'Hungarian Notation', each variable has a nice prefix to denote its data type, i.e. bIsExciting = false; // Boolean strName = "Gonzo"; // String iNumber = 10; // Integer While this style of notation has fallen out of favor, I am seeing (at work, internet, etc.) a lot of data type indicators added as a ' suffix ' to variable names, i.e. NameStr = "Gonzo"; // String NumberInt = 10; // Integer MyRideBike = new Bike(); // Bicycle Is there a name for this,

Any valid reason for code duplication? [closed]

不羁的心 提交于 2019-12-19 05:05:02
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I'm currently reviewing a very old C++ project and see lots of code duplication there. For example,

Are hard-coded STRINGS ever acceptable?

自闭症网瘾萝莉.ら 提交于 2019-12-19 04:21:30
问题 Similar to Is hard-coding literals ever acceptable?, but I'm specifically thinking of "magic strings" here. On a large project, we have a table of configuration options like these: Name Value ---- ----- FOO_ENABLED Y BAR_ENABLED N ... (Hundreds of them). The common practice is to call a generic function to test an option like this: if (config_options.value('FOO_ENABLED') == 'Y') ... (Of course, this same option may need to be checked in many places in the system code.) When adding a new

An algorithm to “spacify” CamelCased strings

徘徊边缘 提交于 2019-12-19 04:18:07
问题 Pretty basic, I'm just curious how others might implement this algorithm and would like to see if there are any clever tricks to optimize the algorithm...I just had to implement this for a project that I am working on. Given a string in CamelCase, how would you go about "spacifying" it? e.g. given FooBarGork I want Foo Bar Gork back. Here is my algorithm in C#: static void Main(string[] args) { Console.WriteLine(UnCamelCase("FooBarGork")); } public static string UnCamelCase(string str) {

Fast axis aligned cell traversal algorithm

我只是一个虾纸丫 提交于 2019-12-19 03:55:30
问题 Given an axis aligned square divided in four cells of equal size A, B, C and D. Given a line segment going from point s1 to point s2. What is the fastest way to find the cells traversed by the segment (if any), sorted by traversal order ? In the example above, the correct results are : Segment 1 : [D] Segment 2 : [A, B] Segment 3 : [C, D, B] Segment 4 : [] Segment 5 : [C] 回答1: You can try "A Fast Voxel Traversal Algorithm for Ray Tracing" by Amanatides and Woo. It is intended to deal with big

Fast axis aligned cell traversal algorithm

倾然丶 夕夏残阳落幕 提交于 2019-12-19 03:55:12
问题 Given an axis aligned square divided in four cells of equal size A, B, C and D. Given a line segment going from point s1 to point s2. What is the fastest way to find the cells traversed by the segment (if any), sorted by traversal order ? In the example above, the correct results are : Segment 1 : [D] Segment 2 : [A, B] Segment 3 : [C, D, B] Segment 4 : [] Segment 5 : [C] 回答1: You can try "A Fast Voxel Traversal Algorithm for Ray Tracing" by Amanatides and Woo. It is intended to deal with big