How to do multiple rotations without losing a degree of freedom? - three.js

I'm trying to display multiple "3d lines" imported from an XML file. I simply need to draw simple rectangular boxes using the provided parameters (5 x 5 x "length"), move it at the right position and rotate it using the provided rotations (in degree) - the expected result is multiple shapes starting at the provided position with their length continuing in an orientation that match the provided rotation.
For some shapes, two of the rotation axes are doing the exact same thing - this appear to be a gimbal lock issue (probably amplified because most of the rotations here are at 90 degrees).
I searched and tried multiple solutions for hours, notably using a 4x4 matrix instead of my initial implementation using geometry.rotateX/rotateY/rotateZ. Unfortunately, I'm unable to find a working solution... I found people mentioning quaternions, but I'm not quite sure how to apply this to my current use case...
I'm sure there is a (relatively) easy solution for my issue, but right now, I'm unable to find it... I'm open to any way of doing it, as long as it can be done with the input I have...
Can anyone push me in the right direction?
Thank you so much for your help.
For reference, I'm currently using r124. Here's a simplified example of my parsed input :
var lines = [
{
"length": "150",
"position": {
"x": "100",
"y": "-10",
"z": "1800"
},
"rotation": {
"x": "90",
"y": "0",
"z": "0"
}
},
{
"length": "325",
"position": {
"x": "100",
"y": "-10",
"z": "1800"
},
"rotation": {
"x": "-90",
"y": "-90",
"z": "-90"
}
},
{
"length": "55",
"position": {
"x": "100",
"y": "-10",
"z": "1800"
},
"rotation": {
"x": "0",
"y": "0",
"z": "-90"
}
}
]

Related

increase by 50 all numbers of lines with "y" coordinate

I need help. The problem: how to change all specific coordinate values by any number. Like multiplying all values of Y coordinates here by 3 or decreasing all X values by 55.
There is notepad file format with many many lines in it. Tbh thats a hideout file from path of exile game. I want to edit some objects there, so i need to manage coordinate values somehow. The reason why i want it - to share with PoE community some hideout files, but i need to move objects in it to make everything looking good.
I am have no clue how to solve it. I hope to find some wise person here <3
Example:
"Arched Gateway": {
"hash": 3294752266,
"x": 309,
"y": 237,
"r": 1756,
"fv": 0
},
"Arched Gateway": {
"hash": 3294752266,
"x": 305,
"y": 259,
"r": 4586,
"fv": 0
},
"Arched Gateway": {
"hash": 3294752266,
"x": 261,
"y": 302,
"r": 11101,
"fv": 0
},
I want to find out the wat to solve it not manually. Like function in any app or site which can change only Y coordinate values.
You can write a JSONata expression to transform your data, see https://try.jsonata.org/.
But first, you need to fix your data as it's not a valid JSON, because of duplicate key 'Arched Gateway'.
If you modify your input like this for example:
{
"ArchedGateways": [{
"hash": 3294752266,
"x": 309,
"y": 237,
"r": 1756,
"fv": 0
},
{
"hash": 3294752266,
"x": 305,
"y": 259,
"r": 4586,
"fv": 0
},
{
"hash": 3294752266,
"x": 261,
"y": 302,
"r": 11101,
"fv": 0
}
]
}
this JSONata expression would do:
ArchedGateways.{
'hash': hash,
'x': x - 55,
'y': y * 3,
'r': r,
'fv': fv
}

How to filter string prefixes with Vega-lite

Is it possible to filter records with Vega-lite by strings?
Example:
record: "ABCD"
record: "AMFK"
record: "AMRK"
I would like to process only records where the string starts with "AM".
I studied the documentation and found solutions only for comparing the entire string. Is it possible to truncate the string? Or use something like "LEFT()" in Excel? Or something completely different?
Edit:
Possibly of importance, I'm using the Vega-lite app in Airtable.
You can do this using a filter transform along with an appropriate vega expression. For example (open in editor):
{
"data": {
"values": [
{"key": "ABCD", "value": 1},
{"key": "AMFK", "value": 2},
{"key": "AMRK", "value": 3}
]
},
"transform": [{"filter": "slice(datum.key, 0, 2) == 'AM'"}],
"mark": "bar",
"encoding": {
"x": {"type": "quantitative", "field": "value"},
"y": {"type": "nominal", "field": "key"}
}
}

Cannot get ui_guage to display each message after specified delay time

My experiment is to change the ui_guage according to the numbers from a csv file. Each number is delayed for 5 sec.(code at end)
Input to csv file is a multi-line msg.payload with three values per line.i.e,
name1, numerical1,numerical11
name2 numerical2,numerical22, etc
problem: i get no delay of 5sec per message on the gauge...it directly shows the final value present in the last column (i have used a delay node also but still...)
example: display column 3 numericals as indicator with 5 sec delay on gauge.
gauge output: numerical22 (the indicator sets to this position at once)
So, the required per message delay (5 sec) is absent.
I require the delay.
I'am working on IBM cloud lite plan, node red v1.0.6
please review the following code
any help is welcome
if similar is answered before please re-direct me the solution.
To run following code:
open Node-RED
Click the three lines (top right)
import
Copy & paste the following flow json code and click "import" button
know more : Importing and Exporting Flows in Node-RED
The code:
[
{
"id": "c9b43c3a.da2e4",
"type": "ui_gauge",
"z": "ac0d0d22.69ebb",
"name": "",
"group": "c604d450.9712c8",
"order": 13,
"width": "5",
"height": "5",
"gtype": "gage",
"title": "<img height=\"50\" width=\"50\" src=\"https://upload.wikimedia.org/wikipedia/commons/b/bf/Pressure_gauge.svg\"/>",
"label": "units",
"format": " {{msg.payload.col3}}",
"min": 0,
"max": 10,
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 840,
"y": 320,
"wires": []
},
{
"id": "c604d450.9712c8",
"type": "ui_group",
"z": "",
"name": "tab1",
"tab": "c733c61c.6e4828",
"order": 1,
"disp": true,
"width": "12",
"collapse": false
},
{
"id": "c733c61c.6e4828",
"type": "ui_tab",
"z": "",
"name": "Home1",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]

Specify aspect ratio / equal scales on Vegalite plot

On an Vegalite xy chart, how do I specify the data aspect ratio to 1? In other words, I want the same scaling from data to plot units for both x and y axes. In Matplotlib this is achieved with matplotlib.axes.Axes.set_aspect('equal'). How would I modify the following spec snippet?
{
"width": 500,
"height": 500
"mark": {"type": "line", "point": {"size": 0}},
"encoding": {
"x": {"field": "y", "type": "quantitative"},
"y": {"field": "x", "type": "quantitative"},
"color": {
"field": "run",
"type": "nominal",
"scale": {"scheme": "magma"}
}
}
}
Vega-lite and altair don't have an aspect argument or set_aspect method like in matplotlib. I had a same question earlier this week and this is the answer that I got from one of the devs;
It’s definitely possible to change the width/height of a figure, which
is almost the same thing See
https://altair-viz.github.io/gallery/aggregate_bar_chart.html for an
example
So as long as your width and height have the same value then by default the aspect will also be equal.

Microsoft LUIS builtin.number

I used builtin.number in my LUIS app trying to collect a 4 digit pin number. The following is what's returned from LUIS when my input is "one two three four".
"entities": [
{
"entity": "one",
"type": "builtin.number",
"startIndex": 0,
"endIndex": 2,
"resolution": {
"value": "1"
}
},
{
"entity": "two",
"type": "builtin.number",
"startIndex": 4,
"endIndex": 6,
"resolution": {
"value": "2"
}
},
{
"entity": "three",
"type": "builtin.number",
"startIndex": 8,
"endIndex": 12,
"resolution": {
"value": "3"
}
},
{
"entity": "four",
"type": "builtin.number",
"startIndex": 14,
"endIndex": 17,
"resolution": {
"value": "4"
}
},
As you can see, it's returning individual digits in both text and digit format. Seems to me that it's more important to return the whole digit than the individual ones. Is there a way to do it so that I get '1234' as result for builtin.number?
Thanks!
It's not possible to do what you're asking for by only using LUIS. The way LUIS does its tokenization is that it recognizes each word/number individually due to the whitespace. It goes without saying that 'onetwothreefour' will also not return 1234.
Additionally, users are unable to modify the recognition of the prebuilt entities on an individual model level. The recognizers for certain languages are open-source, and contributions from the community are welcome.
All of that said, a way you could achieve what you're asking for is by concatenating the numbers. A JavaScript example might be something like the following:
var pin = '';
entities.forEach(entity => {
if (entity.type == 'builtin.number') {
pin += entity.resolution.value;
}
}
console.log(pin); // '1234'
After that you would need to perform your own handling/regexp, but I'll leave that to you. (after all, what if someone provides "seven eight nine ten"? Or "twenty seventeen"?)

Resources