Based on another thread (Raphaeljs transformations with sets)
I have played around with inherited transformations using sets in sets.
I tried to put a set in another set and each set would apply a 45° rotation. I expected, that both rotation would sum up to a 90° rotation. That is working fine.
But both rotations are relative to the centerpoint of each single Object in the Set. How can I achieve, that the rotations are relative to the center point of the Set? Is this possible?
To clarify what I mean. If I have two rectangles in a set and I apply a rotation on the set, I want that the rectangles will stay in the same position and angle relative to them self, because they both rotate around an axis that is between them, in the middle of the set. So they must be translated additionally to the rotation...
how can I achieve this?
jsfiddle:http://jsfiddle.net/bBy9b/
var paper = Raphael(0,0,500,500);
var a = paper.rect(10,10,50,10);
var b = paper.rect(10,30,50,10)
var c = paper.rect(10,50,50,10);
var d = paper.rect(10,70,50,10);
var set = paper.set()
set.push(a);
set.transform("r-45");
var rootSet = paper.set();
rootSet.push(set, b, c);
rootSet.transform("...r-45");
Thx for your help in advance!
The r command takes two additional optional parameters which are the centre point of the rotation. So it looks like you want something like this:
window.onload = function(){
var paper = Raphael(0,0,500,500);
var a = paper.rect(10,10,50,10);
var b = paper.rect(10,30,50,10)
var c = paper.rect(10,50,50,10);
var d = paper.rect(10,70,50,10);
var set = paper.set()
set.push(a);
set.transform("...r-45,40,45");
var rootSet = paper.set();
rootSet.push(set, b, c);
rootSet.transform("...r-45,40,45");
}
Related
I try to get Daily LST data from Google Earth Engine.
Here is my code;
// Import image collection
var modis = ee.ImageCollection('MODIS/061/MOD11A1');
// A start date is defined and the end date is determined by advancing 1 year from the start date.
var start = ee.Date('2012-01-01');
var dateRange = ee.DateRange(start, start.advance(1, 'year'));
// Filter the LST collection to include only images from time frame and select day time temperature band
var modLSTday = modis.filterDate(dateRange).select('LST_Day_1km')
.map(function(image){return image.clip(studyArea)});
// Scale to Kelvin and convert to Celsius, set image acquisition time.
var modC = modLSTday.map(function(image) {
return image
.multiply(0.02)
.subtract(273.15)
.copyProperties(image, ['system:time_start']);
});
//Convert data to bands
var daily = modC.toBands();
//Creating sample points in the given geometry(study area; assets or simple rectangle)
var Sample_points = daily.sampleRegions({
collection: studyArea,
scale: 500,
geometries: true
});
//Getting LST values from sample points
var collection_with_latlon = Sample_points.map(function (feature) {
var coordinates = feature.geometry().transform('epsg:4326').coordinates();
return feature.set('lon', coordinates.get(0), 'lat', coordinates.get(1));
});
My problem is daily variable is not create sample points and does not get LST values. I used the same code for NDVI data, it works perfectly but in LST data it is not working.
when I use the;
var Sample_points = daily.select(2).sampleRegions({
collection: studyArea,
scale: 500,
geometries: true
});
SampleRegions works and gets LST values to the csv table in my drive. But it works for just one image. I need to get 366 images (a year) data.
Please give me some help...
I'm trying to make a script that will find the width of an item and check if the selected item width is the same and then show an alert.
For some reason my if condition is not working even when all the conditions are met.
Here is my code:
var doc = app.activeDocument;
function mm(n) {return n / 2.83464566929134;}
function pt(n) {return n * 2.83464566929134;}
//=====================
// Calculate Prisa
//=====================
var prisa = doc.pathItems.getByName("prisa");
var prisawidth = mm(prisa.geometricBounds[2]-prisa.geometricBounds[0]);
//=========================
// Calculate Selection
//=========================
var sel = doc.selection[0];
var selwidth = mm(sel.geometricBounds[2]-sel.geometricBounds[0]);
if (selwidth == prisawidth) {alert("Same Width");}
You can try this:
if (Math.abs(selwidth - prisawidth) < .01) alert("About the same width");
I think the problem has to do with rounding of the numbers. Say, you can see '2 mm' and '2 mm', but actually there are '2.00001 mm' and '2.00002 mm' or something like this. So it's need either to round the fugures before compairing or check if the diffference is less than some minimal value.
As you can see in the below image. I want to add custom label ranges for y axis.
I have followed this tutorial and tried below code but it was not working, Any idea how to use categoryAxis with custom labels?
let range0 = categoryAxis.axisRanges.create();
range0.value = "MCR.INV-1";
range0.text = "MCR.INV-1";
let range500 = categoryAxis.axisRanges.create();
range500.value = "MCR.INV-2";
range500.text = "MCR.INV-2";
let range1000 = categoryAxis.axisRanges.create();
range1000.value = "PEV1.INV-1";
range1000.text = "PEV1.INV-1";
CategoryAxis ranges use category/endCategory for placement. Replacing value with category in your ranges will fix the problem.
I was wondering if someone is able to assist?
I'm trying to add an Arrayformula consisting of two IF functions, so I'm wanting to merge the following two formulas into one cell:
=ARRAYFORMULA(IF(D13:D104="","",(IF(K13:K104,K13:K104*20,"$0"))))
=ARRAYFORMULA(IF(D105:D="","",(IF(K105:K,K105:K*C4,"$0"))))
So the first section of the sheet needs to be multiplied by 20, and then the figure has changed and needs to be multiplied by 25 (which is cell C4)
Is it possible to merge these into one cell containing an Arrayformula+the two IF functions (or is there another/easier way for this)
Is it possible to add this into Google Apps Script so that it works in the backend (so not just a script that applies the formula into a cell - but doesn't show in the frontend or sheet)
More of a general question - When using Arrayformula with IF; and for example the output is specific text e.g. "Test Complete" associated to the range F2:F (checking if E2:E contains a particular phrase e.g. "Done") - for the empty cells in between (due to setting the False outcome as "") is it possible to somehow randomly add data into these blank cells without interrupting the formula? (so I have to option for automated text if the cell to the left states a particular term/word, but still have the option to manually add random data into blank cells)
Any assistance would be greatly appreciated
As for 1st and 2nd questions: it looks like a task for a custom function. Something like this:
function MULTI() {
var sheet = SpreadsheetApp.getActiveSheet();
var cell = sheet.getActiveCell();
var row = cell.getRow();
var value = sheet.getRange('K'+row).getValue();
return (row < 105) ? value * 20 : value * 25;
}
It gets a value from column K and multiplies it by 20 if the row less than 105 and by 25 for the rest of rows.
Here is the variant of the same formula that uses the cell 'C4':
function MULTIC4() {
var sheet = SpreadsheetApp.getActiveSheet();
var cell = sheet.getActiveCell();
var row = cell.getRow();
var value = sheet.getRange('K'+row).getValue();
var c4 = sheet.getRange('C4').getValue();
return (row < 105) ? value * 20 : value * c4;
}
And it can be done with the trigger onEdit():
function onEdit(e) {
var col = e.range.columnStart;
if (col != 11) return; // 11 = K
var sheet = e.source.getActiveSheet();
if (sheet.getName() != 'Sheet1') return;
var c4 = sheet.getRange('C4').getValue();
var row = e.range.rowStart;
var dest_cell = sheet.getRange('D'+row);
var value = sheet.getRange(row,col).getValue();
var result = (row < 105) ? value * 20 : value * c4;
dest_cell.setValue(result);
}
It recalculates automatically the value in the cell of column 'D' (current row) every time when you're changing value in the cell of column 'K'. On the sheet 'Sheet1'.
I am wondering if something that i would like to achieve is possible, please look at the picture and read description below:
I would like to add a column to the right, where if a cell table[ActionType] = "TERMINATING", it calculates a difference between timestamps (timestamp for TERMINATING - timestamp for STARTING in below row). If the result is positive (>0) then store it in a column in a corresponding row (eg next to timestapm for terminating), if result is negative don't store it. And all of that applied to whole table.
I tried conditional column and i guess it cannot be done with this or at least I couldn't make it.
Will be very thankful for responses and tips!
Pre-requisite :- Add an Index Column using the query editor. Make sure they are in the next row to each other.
It is advisable to keep TimeStamp column as a DateTime Column itself.
So, if you can change your TimeStamp column to a DateTime column then try this :-
Difference =
Var Get_Action_Type = Table1[ActionType]
Var required_Index_1 = Table1[Index] + 1
Var required_Index = IF(required_Index_1 > MAX(Table1[Index]),required_Index_1-1, required_Index_1)
Var Current_Action_TimeStamp = Table1[TimeStamp]
Var next_Action_TimeStamp = CALCULATE(MAX(Table1[TimeStamp]),FILTER(Table1, Table1[Index] = required_Index))
Var pre_result = IF(Get_Action_Type = "TERMINATING", DATEDIFF(Current_Action_TimeStamp, next_Action_TimeStamp,SECOND), BLANK())
Var result = IF(pre_result > 0, pre_result, BLANK())
return result
And if you cannot change it to a Date Time, then try this calculated column,
Difference_2 =
Var Get_Action_Type = Table1[ActionType]
Var required_Index_1 = Table1[Index] + 1
Var required_Index = IF(required_Index_1 > MAX(Table1[Index]),required_Index_1-1, required_Index_1)
Var Current_Action_TimeStamp = Table1[Time_Stamp_Number]
Var next_Action_TimeStamp = CALCULATE(MAX(Table1[Time_Stamp_Number]),FILTER(Table1, Table1[Index] = required_Index))
Var pre_result = IF(Get_Action_Type = "TERMINATING", next_Action_TimeStamp - Current_Action_TimeStamp, BLANK())
Var result = IF(pre_result > 0, pre_result, BLANK())
return result
The Output looks as below :-
Kindly accept the answer if it helps and do let me know, how it works for you.