logo
down
shadow

Ball splitting and merging


Ball splitting and merging

Content Index :

Ball splitting and merging
Tag : visual-cpp , By : Tom Berthon
Date : November 25 2020, 07:06 PM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Splitting up/merging windows in WPF


Tag : chash , By : Tom D
Date : March 29 2020, 07:55 AM
Hope that helps It sounds to me like you'd want to create a UserControl and put gridFirst in it. That way you can add your user control to your main grid and your window.
If the DataContext of your control is the same then it should look the same where ever you put it.

Merging, then splitting files


Tag : bash , By : user186435
Date : March 29 2020, 07:55 AM
I wish this help you Instead of that for loop for concatenating, you can just use cat *.txt.
Anyway, why don't you just perform the scripts on each file independently within the for loop?
for filename in *.txt; do
    cat "${filename}"
    echo "@@@@@"
done > output.txt

# Pass output.txt through whatever

awk 'BEGIN { fileno = 1; file = sprintf("output%02d.txt", fileno) }; 
     { if($1 ~ /@@@@@/) { fileno++; 
                          file = sprintf("output%02d.txt", fileno); 
                          next } 
       else print >file 
     }' output.txt

Splitting, merging, sorting CSV


Tag : python , By : Michael Gunderson
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further If I understand correctly, you have multiple files, each corresponding to a given "sensor", with the identity of the sensor in the filename. You want to read the files, then write them out in to separate files again, this time divided by "source", with the data from the different sensors combined into several final rows.
Here's what I think you want to do:
from collections import defaultdict
from datetime import datetime
import csv
import glob
import os

# data structure is data[source][date, time][sensor] = value, with "" as default value
data = defaultdict(lambda: defaultdict(lambda: defaultdict(str)))
sensors = []

filelist = glob.glob("*.csv")

# read old files
for fn in filelist:
    sensor = os.path.splitext(fn)[0]
    sensors.append(sensor)
    with open(fn, 'rb') as f:
        reader = csv.DictReader(f, delimiter=";")
        for row in reader:
            date = datetime.strptime(row['date'], '%m/%d/%y')
            data[row['source']][date, row['hour']][sensor] = row['values']

sensors.sort() # note, this may not give the best sort order
header = ['date', 'hour', 'source'] + sensors

for source, source_data in data.iteritems():
    fn = "{}.csv".format(source)
    with open(fn, 'wb') as f:
        writer = csv.writer(f, delimiter=";")
        writer.writerow(header)
        for (date, time), hour_data in sorted(source_data.items()):
            values = [hour_data[sensor] for sensor in sensors]
            writer.writerow([date.strftime('%m/%d/%y'), time, source] + values)

Ball to ball elastic collision: ball bounces in an unequal proportion


Tag : javascript , By : alexandruz
Date : March 29 2020, 07:55 AM
I hope this helps . 1) You should clarify your code, as it stands it is a bit complex, this is in itself a bug source.
2) You're doing some strange things with v1n/t v2n/t : projecting + squaring the speed on X ...??? I didn't even try to understand the b1.velocity code. Ouch ! :-)
function resolveCollision(b1, b2) {
    var v1x = b1.vx,
        v2x = b2.vx,
        v1y = b1.vy,
        v2y = b2.vy;

    // Collision vector
    var delta = {
        x: b2.x - b1.x,
        y: b2.y - b1.y
    };
    var d = length(delta);

    // Normalized collision vector
    var dn = {
        x: delta.x / d,
        y: delta.y / d
    }

    // Normalized tangent collision vector
    var dt = {
        x: dn.y,
        y: -dn.x
    };

    var m1 = b1.m;
    var m2 = b2.m;
    var M = m1 + m2;

    /*    
    // test those separation tricks in a second time
    if (d === 0) {
        b2.x += 0.01;
    }
    var mt = {
        x: dn.x * (b1.r + b2.r - d),
        y: dn.y * (b1.r + b2.r - d)
    };    
    b1.x = b1.x + mt.x * m2 / M
    b1.y = b1.y + mt.y * m2 / M
    b2.x = b2.x + mt.x * m1 / M
    b2.y = b2.y + mt.y * m1 / M
    */

    // projection of v1 on the collision vector
    var v1Proj = {
        n: dn.x * v1x + dn.y * v1y,
        t: dt.x * v1x + dt.y * v1y
    };

    // projection of v2 on the collision vector
    var v2Proj = {
        n: dn.x * v2x + dn.y * v1y,
        t: dt.y * v2x + dt.y * v2y
    };

    // solving collision on the normal
    var newV1ProjN = ((m1 - m2) * v1Proj.n + 2 * m2 * v2Proj.n) / M;
    var newV2ProjN = ((m2 - m1)* v2Proj.n + 2 * m1 * v1Proj.n) / M;

    // re-building speed vector out of projected vectors
    b1.vx = newV1ProjN * dn.x + v1Proj.t * dt.x;
    b1.vy = newV1ProjN * dn.y + v1Proj.t * dt.y;

    b2.vx = newV2ProjN * dn.x + v2Proj.t * dt.x;
    b2.vy = newV2ProjN * dn.y + v2Proj.t * dt.y;
}

function dot(v1, v2) {
    return v1.x * v2.x + v1.y * v2.y;
};

function length(v) {
    return Math.sqrt(v.x * v.x + v.y * v.y);
};

What happens when the following code executes? Ball *ball = [[[[Ball alloc] init] autorelease] autorelease];


Tag : iphone , By : KaoFloppy
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
shadow
Privacy Policy - Terms - Contact Us © scrbit.com