AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-1390192

tmighty's questions

Martin Hope
tmighty
Asked: 2024-12-18 00:29:40 +0800 CST

Por que uma rotação Maxtrix produz extensões "erradas" e como posso corrigir isso?

  • 6

Estou usando o Cairo Graphics junto com o RichClient6 (que é um wrapper), mas acredito que esse fato não seja tão importante.

Preciso obter as extensões de um caminho. Isso funciona bem, mas não quando a matriz é rotacionada. Não entendo o que acontece neste caso, e ainda não consegui resolver sozinho.

Gostaria de perguntar se alguém vê o que preciso fazer de diferente para obter as extensões de forma confiável, mesmo quando a matriz é rotacionada.

Obrigado.

Aqui estão algumas saídas que mostram como as extensões mudam:

Angle: 1, Path Extents:    -2,8         -6     343,8         169 
Angle: 2, Path Extents:    -5,7         -11,9   346,7        174,9 
Angle: 3, Path Extents:    -8,5         -17,8   349,5        180,8 
Angle: 4, Path Extents:    -11,3         -23,7  352,3        186,7 
Angle: 5, Path Extents:    -14,2         -29,6  355,2        192,6 
Angle: 6, Path Extents:    -16,9         -35,4  357,9        198,4 
Angle: 7, Path Extents:    -19,7         -41,2  360,7        204,2 
Angle: 8, Path Extents:    -22,5         -47    363,5        210 
Angle: 9, Path Extents:    -25,2         -52,7  366,2        215,7 
Angle: 10, Path Extents:   -27,9         -58,3  368,9       221,3 
Angle: 11, Path Extents:   -30,5         -63,9  371,5       226,9 
Angle: 12, Path Extents:   -33,2         -69,4  374,1       232,3 
Angle: 13, Path Extents:   -35,7         -74,7  376,7       237,7 
Angle: 14, Path Extents:   -38,3         -80    379,3        243 
Angle: 15, Path Extents:   -40,7         -85,2  381,7       248,3 
Angle: 16, Path Extents:   -43,2         -90,4  384,2       253,4 
Angle: 17, Path Extents:   -45,6         -95,3  386,6       258,3 
Angle: 18, Path Extents:   -47,9         -100,2           388,9  263,2 
Angle: 19, Path Extents:   -50,2         -105  391,2        268 
Angle: 20, Path Extents:   -52,4         -109,6           393,4  272,6 
Angle: 21, Path Extents:   -54,5         -114,1           395,5  277,1 
Angle: 22, Path Extents:   -56,6         -118,4           397,6  281,4 
Angle: 23, Path Extents:   -58,6         -122,6           399,6  285,6 
Angle: 24, Path Extents:   -60,6         -126,7           401,6  289,7 
Angle: 25, Path Extents:   -62,4         -130,6           403,4  293,6 
Angle: 26, Path Extents:   -64,2         -134,4           405,2  297,4 
Angle: 27, Path Extents:   -65,9         -137,9           406,9  300,9 
Angle: 28, Path Extents:   -67,6         -141,4           408,6  304,4 
Angle: 29, Path Extents:   -69,1         -144,6           410,1  307,6 
Angle: 30, Path Extents:   -70,6         -147,7           411,6  310,7 
Angle: 31, Path Extents:   -72          -150,5  413        313,5 
Angle: 32, Path Extents:   -73,3         -153,2           414,3  316,2 
Angle: 33, Path Extents:   -74,5         -155,8           415,5  318,8 
Angle: 34, Path Extents:   -75,6         -158,1           416,6  321,1 
Angle: 35, Path Extents:   -76,6         -160,2           417,6  323,2 
Angle: 36, Path Extents:   -77,5         -162,2           418,5  325,2 
Angle: 37, Path Extents:   -78,3         -163,9           419,3  326,9 
Angle: 38, Path Extents:   -79,1         -165,4           420,1  328,4 
Angle: 39, Path Extents:   -79,7         -166,8           420,7  329,8 
Angle: 40, Path Extents:   -80,3         -167,9           421,3  330,9 
Angle: 41, Path Extents:   -80,7         -168,8           421,7  331,8 
Angle: 42, Path Extents:   -81,1         -169,6           422,1  332,6 
Angle: 43, Path Extents:   -81,3         -170,1           422,3  333,1 
Angle: 44, Path Extents:   -81,5         -170,4           422,5  333,4 
Angle: 45, Path Extents:   -81,5         -170,5           422,5  333,5 
Angle: 46, Path Extents:   -81,5         -170,4           422,5  333,4 
Angle: 47, Path Extents:   -81,3         -170,1           422,3  333,1 
Angle: 48, Path Extents:   -81,1         -169,6           422,1  332,6 
Angle: 49, Path Extents:   -80,7         -168,8           421,7  331,8 
Angle: 50, Path Extents:   -80,3         -167,9           421,3  330,9 
Angle: 51, Path Extents:   -79,7         -166,8           420,7  329,8 
Angle: 52, Path Extents:   -79,1         -165,4           420,1  328,4 
Angle: 53, Path Extents:   -78,3         -163,9           419,3  326,9 
Angle: 54, Path Extents:   -77,5         -162,2           418,5  325,2 
Angle: 55, Path Extents:   -76,6         -160,2           417,6  323,2 

E este é o código:

 Public Sub DrawTo(ByRef uDestCC As cCairoContext, ByVal uLeft As Long, ByVal uTop As Long)

    Dim dblOffx As Double: Dim dblOffy As Double

    ' Calculate offsets based on alignment and scaling
    dblOffx = Me.AlignmentFactorX * ((m_Img.width * Me.ScaleFactorW) / 2)
    dblOffy = Me.AlignmentFactorY * ((m_Img.height * Me.ScaleFactorH) / 2)

    Dim dblNewX1 As Double :  Dim dblNewY1 As Double
    dblNewX1 = (uLeft + dblOffx)
    dblNewY1 = (uTop + dblOffy)
    
    Dim dblNewX2 As Double : Dim dblNewY2 As Double
    dblNewX2 = -(m_Img.width / 2) - (Me.CenterOffsetX / 2)
    dblNewY2 = -(m_Img.height / 2) - (Me.CenterOffsetY / 2)

    m_Matrix.TranslateCoords dblNewX1, dblNewY1
    m_Matrix.RotateCoordsDeg m_sngAngleDeg
    m_Matrix.ScaleCoords Me.ScaleFactorW, Me.ScaleFactorH
    m_Matrix.TranslateCoords dblNewX2, dblNewY2
    
    ' Set the final transformation
    Set uDestCC.Matrix = m_Matrix
    
    ' Now draw the image with the same transformations
    uDestCC.RenderSurfaceContent m_Img, 0, 0

    ' Define a rectangle path representing the image area after rotation is set
    uDestCC.Rectangle 0, 0, m_Img.width, m_Img.height

    ' Get the extents now, with rotation already applied
    uDestCC.GetPathExtents m_dblTopX, m_dblTopY, m_dblBottomRightX, m_dblBottomRightY

    ' Clear the path
    uDestCC.ClearPath False
    
    m_Matrix.ResetToIdentity
    
    Debug.Print "Angle: " & m_sngAngleDeg & ", Path Extents:", Round(m_dblTopX, 1), Round(m_dblTopY, 1), Round(m_dblBottomRightX, 1), Round(m_dblBottomRightY, 1)
    
End Sub

Alguém sugere usar o CopyPath.

No invólucro encontrei isto:

Function CopyPath([AsFlatPath As Boolean], [FlatPrecision As Double = 0,1]) As cCairoPath
    Member of RC6.cCairoContext

A classe cCairoPath oferece o seguinte:

Function CalculateDistances(Distances() As Double) As Double
Property EntriesCount As Long
Function GetPathEntry(IndexZeroBased As Long, EntryType As cairo_path_data_type_enm, [X0 As Double], [Y0 As Double], [X1 As Double], [Y1 As Double], [X2 As Double], [Y2 As Double])
Sub ProjectPathData_Using(FlattenedBasePath As cCairoPath, [ScaleX As Double], [ScaleY As Double])
Sub ProjectPathData_Using(FlattenedBasePath As cCairoPath, [ScaleX As Double], [ScaleY As Double])
math
  • 1 respostas
  • 18 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Reformatar números, inserindo separadores em posições fixas

    • 6 respostas
  • Marko Smith

    Por que os conceitos do C++20 causam erros de restrição cíclica, enquanto o SFINAE antigo não?

    • 2 respostas
  • Marko Smith

    Problema com extensão desinstalada automaticamente do VScode (tema Material)

    • 2 respostas
  • Marko Smith

    Vue 3: Erro na criação "Identificador esperado, mas encontrado 'import'" [duplicado]

    • 1 respostas
  • Marko Smith

    Qual é o propósito de `enum class` com um tipo subjacente especificado, mas sem enumeradores?

    • 1 respostas
  • Marko Smith

    Como faço para corrigir um erro MODULE_NOT_FOUND para um módulo que não importei manualmente?

    • 6 respostas
  • Marko Smith

    `(expression, lvalue) = rvalue` é uma atribuição válida em C ou C++? Por que alguns compiladores aceitam/rejeitam isso?

    • 3 respostas
  • Marko Smith

    Um programa vazio que não faz nada em C++ precisa de um heap de 204 KB, mas não em C

    • 1 respostas
  • Marko Smith

    PowerBI atualmente quebrado com BigQuery: problema de driver Simba com atualização do Windows

    • 2 respostas
  • Marko Smith

    AdMob: MobileAds.initialize() - "java.lang.Integer não pode ser convertido em java.lang.String" para alguns dispositivos

    • 1 respostas
  • Martin Hope
    Fantastic Mr Fox Somente o tipo copiável não é aceito na implementação std::vector do MSVC 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant Encontre o próximo dia da semana usando o cronógrafo 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor O inicializador de membro do construtor pode incluir a inicialização de outro membro? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský Por que os conceitos do C++20 causam erros de restrição cíclica, enquanto o SFINAE antigo não? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul O C++20 mudou para permitir a conversão de `type(&)[N]` de matriz de limites conhecidos para `type(&)[]` de matriz de limites desconhecidos? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann Como/por que {2,3,10} e {x,3,10} com x=2 são ordenados de forma diferente? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller O ponto e vírgula agora é opcional em condicionais bash com [[ .. ]] na versão 5.2? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench Por que um traço duplo (--) faz com que esta cláusula MariaDB seja avaliada como verdadeira? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng Por que `dict(id=1, **{'id': 2})` às vezes gera `KeyError: 'id'` em vez de um TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob: MobileAds.initialize() - "java.lang.Integer não pode ser convertido em java.lang.String" para alguns dispositivos 2024-03-20 03:12:31 +0800 CST

Hot tag

python javascript c++ c# java typescript sql reactjs html

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve