Sunday, March 26, 2017
Rolling on the Floor Laughing
Its a hilariously true story. :)
One can think of so many things along these lines...
I laugh at so many times where failure passes, the mistaken reckoning of being too human...
No offense, by the way...
One can think of so many things along these lines...
I laugh at so many times where failure passes, the mistaken reckoning of being too human...
No offense, by the way...
Saturday, March 25, 2017
Friday, March 17, 2017
Typescript/JavaScript Angular Problem: Hashmap a dictionary of rescaled one dimensional coordinate values to their corresponding indices for a position based array mapping and more
Okay, so the title is rather a big one, but the problem goes like this:
You've had to squeeze your data down in such a way so that it fits into your canvas graphic...that is, it makes little sense if you have big numbers that can't be viewed because their plot values are outside of the dimension of your screen. This problem is of 'squeezing' the data is otherwise re scaling it so that it fits into visual dimensions that can be read. Its really not a big deal doing that since you can refactor a plot without changing its shape/form attributes by using a global scale factor. But let's say you wanted to have a quick and easy search algorithm that matches a screen based coordinate that a user has supplied, say from mouseover position that relates to a position on the graph or at least as directly related to your big data. How to do this?
As it turns out you may have stored your big data, in some sort of collection type that contains points which may have something like: x, y in 2 dimensions, and this collection type may be structured in the form of an array. The problem is that with any mouseover, your first inclination may be to search the set of points and then break at a common match, but this is slow! I say this since you are constantly search iterating points to find the match based on a screen position that is supplied. Why not create an inverse map on the set of points and hashmap these?
As it turns out you can do it in Typescript/Javascript, but as I found out, keys say with the {} type string values. If your data is on the other hand given by positions which are 'number' types you'd first have to likely Math.round(), Math.floor() or Math.ceiling your numbers. Then you'd convert this to string using the position.x.toString(), 'number' types have a .toString() method. Then you'd key the value while storing its array index in value position.
A sketch:
In a given data range set of points, it is important to keep in mind that keying position data means also that truncation (by floor, rounding, or ceiling a number) may necessarily supply more than one position for a given key, and for this you may need to bucket the values in an array, and provide additional searching algorithms in refining a search, but at least this method provides nice fast lookup position addressing.
So when you search you need to account for undefined key values. These are screen positions that do not have a corresponding key in, for instance, inverse2dVectorsMap. For this, you simply omit the user supplied position until they have sufficiently toggled a position that corresponds to a point on the data set.
And example sketch:
Then filter 'undefined' return values relative to non 'undefined' ones.
For example:
You've had to squeeze your data down in such a way so that it fits into your canvas graphic...that is, it makes little sense if you have big numbers that can't be viewed because their plot values are outside of the dimension of your screen. This problem is of 'squeezing' the data is otherwise re scaling it so that it fits into visual dimensions that can be read. Its really not a big deal doing that since you can refactor a plot without changing its shape/form attributes by using a global scale factor. But let's say you wanted to have a quick and easy search algorithm that matches a screen based coordinate that a user has supplied, say from mouseover position that relates to a position on the graph or at least as directly related to your big data. How to do this?
As it turns out you may have stored your big data, in some sort of collection type that contains points which may have something like: x, y in 2 dimensions, and this collection type may be structured in the form of an array. The problem is that with any mouseover, your first inclination may be to search the set of points and then break at a common match, but this is slow! I say this since you are constantly search iterating points to find the match based on a screen position that is supplied. Why not create an inverse map on the set of points and hashmap these?
As it turns out you can do it in Typescript/Javascript, but as I found out, keys say with the {} type string values. If your data is on the other hand given by positions which are 'number' types you'd first have to likely Math.round(), Math.floor() or Math.ceiling your numbers. Then you'd convert this to string using the position.x.toString(), 'number' types have a .toString() method. Then you'd key the value while storing its array index in value position.
A sketch:
public setScreenXCoords(){
//called after screen coordinates have been setSceenXCoords
//and that this.points is a screen coordinate set.
var i = 0;
for (let pvec of this.screenpoints){
let x = pvec.x;
x = Math.round(x);
/*
console.log("key: ");
console.log(x);
console.log("value");
console.log(i);
*/
this.screenToIndex[x.toString()] = i;
i += 1;
}
}
In a given data range set of points, it is important to keep in mind that keying position data means also that truncation (by floor, rounding, or ceiling a number) may necessarily supply more than one position for a given key, and for this you may need to bucket the values in an array, and provide additional searching algorithms in refining a search, but at least this method provides nice fast lookup position addressing.
So when you search you need to account for undefined key values. These are screen positions that do not have a corresponding key in, for instance, inverse2dVectorsMap. For this, you simply omit the user supplied position until they have sufficiently toggled a position that corresponds to a point on the data set.
And example sketch:
public getScreenPoint(xpos: number){
let xpostr = xpos.toString();
if (xpostr in this.screenToIndex){
return this.screenToIndex[xpostr];
}
return undefined;
}
Then filter 'undefined' return values relative to non 'undefined' ones.
For example:
private mouseMoved(e: MouseEvent){
//(mousemove)="mouseMoved($event)"
console.log(e.offsetX);
let xstr = e.offsetX.toString();
console.log("screen index: ");
if (e.offsetX != undefined){
let ind = this.dataCharts[0].getScreenPoint(e.offsetX - 80.0);
console.log(ind);
if (ind != undefined){
this.pointindex[0] = ind;
this.pointindex2 = ind;
}
}
}
Thursday, March 16, 2017
Tip for determining an angular dom event
Dom events in html5 do have a translation to Angular, but it may not be immediately obvious. For instance, in Angular the reference call (click) is equivalent to onclick for the corresponding dom event in Html5 outside of Angular. As it turns the conversion process may follow the rule:
add parenthesis () and then drop the prefix "on" so "onclick" becomes "(click)" or "onmousemove" becomes "(mousemove)". This seems to be a general translation language pattern between Angular and non Angular usage in Html.
Subscribe to:
Posts (Atom)
Oblivion
Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...
-
For starters, as I've seen (pardon my ignorance if I am incorrect), it seems a common way to use path based animated motion for objects...
-
I've looked through a series of web sites on this topic, any number of these ranging in various degrees of technical information, but...
-
Okay so if you read into python scripting examples of moving vertices around in Blender, it seems whether using a bpy.context or bpy.data c...