Size: a a a

2021 January 15

MG

Matthew Good in pro.algorithms
Pavel
Not sure if this even work, but if it is I would start from this and tweak it (e.g. multiply size on some value until it looks decent for your widgets and don't let it be smaller than some value)

H - thumb background height (max possible thumb height)
E - content size (e.g. elements count * element size)
C - container size (on screen)
S - content shift

size = H / max(1.0, E/C)

pos (top corner) is (H-size)*(S/(E-C))
im not sure how that would work
источник

P

Pavel in pro.algorithms
That's hard to read for me from phone (I'll go to sleep in a minute anyway), but if your container size and content shift change correctly during resizing, then you can recalculate the thumb size and position from the new values (not rembering old thumb size and position)
источник

MG

Matthew Good in pro.algorithms
Pavel
That's hard to read for me from phone (I'll go to sleep in a minute anyway), but if your container size and content shift change correctly during resizing, then you can recalculate the thumb size and position from the new values (not rembering old thumb size and position)
my content does not shift when resizing (why would it)
источник

MG

Matthew Good in pro.algorithms
this is what i currently have (which does not work)

int oldTrackWidth = trackWidth;
int newTrackWidth = getWidth();
float locationPercent = (float) thumbX / (float) oldTrackWidth;
thumbX = (int) (newTrackWidth * locationPercent);
if (document != null) {
 float viewportWidth = width;
 float contentWidth = document.getWidth();
 float thumbPercentage = viewportWidth / contentWidth;
 thumbWidth = (int) (trackWidth * thumbPercentage);
}
источник

P

Pavel in pro.algorithms
Matthew Good
my content does not shift when resizing (why would it)
> Why would it?
For example if you at the end of your scroll position and increase the size of your container it would go out of bounds of the content if you don't shift the content
источник

A

Aragaer in pro.algorithms
Вопрос. Есть некоторый вектор - "направление взгляда" - от камеры к некоторой точке. Есть пара x-y, чтобы эту точку сместить (и чтобы камера туда повернулась). Хочется:
- чтобы при нулевом y (то есть поворот влево-вправо) координата z у точки не менялась
- чтобы после поворота сохранялась длина исходного вектора - то есть точка движется по сфере
Получается, что x отвечает за движение вдоль параллели, а y за движение вдоль меридиана на сфере с центром "камера" и радиусом "длина моего вектора". Какую тут надо делать арифметику? Прямо сейчас в итоге сделал через вычисление касательных через векторное умножение, а потом притягивание обратно на сферу. Может есть более разумный способ?
источник

MG

Matthew Good in pro.algorithms
Pavel
> Why would it?
For example if you at the end of your scroll position and increase the size of your container it would go out of bounds of the content if you don't shift the content
why would i go out of bounds? the content would stay where it is right?
источник

A

Aragaer in pro.algorithms
    Vector3 right = Vector3.Cross(Vector3.up, lookVector).normalized;
   Vector3 up = Vector3.Cross(lookVector, right).normalized;
   Vector3 newLookVector = lookVector + right * value.x + up * value.y;
источник

P

Pavel in pro.algorithms
Matthew Good
why would i go out of bounds? the content would stay where it is right?
Example
You have container of visual size 100px and content of size 1000px.
You're at the end of your scroll (position 900px), and showing last 100px of your content. Then you resize your container to be 150px, your content position is still at 900px and you are now showing content from 900px to 1050px (50px out of bounds)
источник

P

Pavel in pro.algorithms
That is easily fixed, but by "correctly" I meant that you covered such cases already.
источник

P

Pavel in pro.algorithms
Yes, I mean if your content scroll working correctly during resize, then to calculate the thumb you can just recalculate it from new size and shift of the content and container
источник

MG

Matthew Good in pro.algorithms
you mean for example, this?
источник

MG

Matthew Good in pro.algorithms
where the grey area is out of bounds
источник

P

Pavel in pro.algorithms
Maybe, not sure, I don't know how you expect it to look like and what are your content bounds. Anyway, good luck with it 🌒
источник

EZ

Evgenii Zheltonozhsk... in pro.algorithms
May because you're asking in totally unrelated chat
источник

AB

Artem Brezhnev in pro.algorithms
О, опять битки
источник
2021 January 16

A

Arelav in pro.algorithms
Aragaer
Вопрос. Есть некоторый вектор - "направление взгляда" - от камеры к некоторой точке. Есть пара x-y, чтобы эту точку сместить (и чтобы камера туда повернулась). Хочется:
- чтобы при нулевом y (то есть поворот влево-вправо) координата z у точки не менялась
- чтобы после поворота сохранялась длина исходного вектора - то есть точка движется по сфере
Получается, что x отвечает за движение вдоль параллели, а y за движение вдоль меридиана на сфере с центром "камера" и радиусом "длина моего вектора". Какую тут надо делать арифметику? Прямо сейчас в итоге сделал через вычисление касательных через векторное умножение, а потом притягивание обратно на сферу. Может есть более разумный способ?
x, y, z = cos a * cos b, cos a * sin b, sin a
a типо долгота, b типо широта
Ну так например
источник

A

Aragaer in pro.algorithms
ну да, но это значит мне надо исходный вектор переводить в полярные координаты, потом делать повороты, а потом обратно
источник

A

Aragaer in pro.algorithms
а у меня вместо этого есть интерфейс с кватернионами
источник

A

Aragaer in pro.algorithms
в итоге сделал так - векторное произведение исходного и (0,0,1) дает мне вектор "вправо". Далее у меня есть кватернион "повернуть вокруг (0,0,1) на нужный угол" и "повернуть вокруг "вправо" на нужный угол", которые я совмещаю и применяю к исходному.
источник