标签: transform

使用转换(STL)时出现C++错误

我在使用transform时面临编译错误:

它与我之前的问题有关:C++:如何将字符串对象复制到int数组?)

enter code here

 class BinaryCode {

    public:
            int get_digit(char c)
            {
                    return c-'0';
            }
            void decode(string decd)
            {
                    int i;

                    std::vector<int>decoded(decd.size());
                    std::transform(decd.begin(), decd.end(), decoded.begin(), get_digit);

                    int length=decoded.length();
Run Code Online (Sandbox Code Playgroud)

错误是:

enter code here

[root@localhost topcoder]# g++ prog1.c
 prog1.c: In member function `void BinaryCode::decode(std::string)':
 prog1.c:20: error: argument of type `int (BinaryCode::)(char)' does not match `int (BinaryCode::*)(char)'
Run Code Online (Sandbox Code Playgroud)

谁能帮帮我吗?我正在使用gcc(g ++)编译器.

c++ linux gcc stl transform

0
推荐指数
1
解决办法
1345
查看次数

UIImageView在触摸方向上旋转动画

我有一个UIImageView有一个箭头的图像.当用户点击UIView时,此箭头应指向水龙头维持其位置的方向,它应该只是改变变换.我已经实现了以下代码.但它没有按预期工作.我添加了截图.在此屏幕截图中,当我触摸左上角时,箭头方向应该如图所示.但是没有发生这种情况.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

 UITouch *touch=[[event allTouches]anyObject];
 touchedPoint= [touch locationInView:touch.view];
 imageViews.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(rangle11));
 previousTouchedPoint = touchedPoint ;
}

- (CGFloat) pointPairToBearingDegrees:(CGPoint)startingPoint secondPoint:(CGPoint) endingPoint
{

 CGPoint originPoint = CGPointMake(endingPoint.x - startingPoint.x, endingPoint.y - startingPoint.y); // get origin point to origin by subtracting end from start
   float bearingRadians = atan2f(originPoint.y, originPoint.x); // get bearing in radians
float bearingDegrees = bearingRadians * (180.0 / M_PI); // convert to degrees
bearingDegrees = (bearingDegrees > 0.0 ? bearingDegrees : (360.0 + bearingDegrees)); // correct …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch transform image-rotation uiimageview ios

0
推荐指数
1
解决办法
1223
查看次数

为什么std :: transform使用构造函数?

我已经使用std :: transform为列表中的现有值添加了一些值.下面的代码工作正常,我只是想知道是否有可能在执行转换时避免对复制构造函数的所有调用(参见程序的输出).如果我只是破解代码,并使for循环显式调用Base的+ =运算符,则不执行复制构造,并且更改位置更有效的值.

我可以使变换调用运算符+ = Base而不是复制构造吗?我应该专注于increment<Type>

该程序:

#include <iostream>
#include<list>
#include <algorithm>
#include <iterator>

template<class T>
class Base;

template<class T>
std::ostream& operator << (std::ostream& os, const Base<T>& b);

template<class T>
class Base
{
    private: 
        T b_;
    public: 
        typedef T value_type;

        Base()
            :
                b_()
        { std::cout << "Base::def ctor" << std::endl; }

        Base (const T& b)
            : 
                b_(b)
        { std::cout << "Base::implicit conversion ctor: " << b_ << std::endl; }

        const T& value()
        {
            return b_;
        }

        const …
Run Code Online (Sandbox Code Playgroud)

c++ optimization stl transform

0
推荐指数
1
解决办法
390
查看次数

我们如何从变换矩阵中得到x和y?

可能的重复:
如何使用转换和矩阵获取SVG中元素的实际x / y位置

我需要获取在SVG中这样编写的元素的x / y位置:

<image
   y="-421.28461"
   x="335.27295"
   id="image2991"
   xlink:href="file:///C:/Users/tom/Documents/t.jpg"
   height="369"
   width="360"
   transform="matrix(0.22297057,0.97482518,-0.97482518,0.22297057,0,0)" />
Run Code Online (Sandbox Code Playgroud)

这里给出了xy属性,但是没有给出图像的实际位置。据我所知

变换矩阵[a,b,c,d,e,f] ef分别在x和y中给出平移轴。但是

问题是,在这里都( e & f )被0。现在我可以我得到实际的x任何y这种形象?

c# math svg transform matrix

0
推荐指数
1
解决办法
1838
查看次数

在C++字符串上使用std转换

我试图用std :: transform进行一些练习,用它来解密一个简单的凯撒密码.但是看起来我的函数定义是错误的,因为编译器认为一元函数参数无效.这是我的代码:

char CryptoModule::UndoCaesar(char& letter)
{
    return (letter - atoi(key_.c_str()) % 128);
}

void CryptoModule::DecryptCaesar()
{
    std::transform(data_.begin(), data_.end(), data_.begin(), UndoCaesar);
}
Run Code Online (Sandbox Code Playgroud)

谁能告诉我错误在哪里?另外,为了使用for_each,我需要修改什么?我相信它会涉及将返回值更改为void并将结果存储在letter中.

感谢,并有一个愉快的一天

编辑:尝试添加绑定,但仍然无法正常工作.目前的电话是:

std::transform(data_.begin(), data_.end(), data_.begin(), bind(&UndoCaesar, this, std::placeholders::_1));
Run Code Online (Sandbox Code Playgroud)

c++ string algorithm transform c++11

0
推荐指数
1
解决办法
1890
查看次数

CGAffineTransformMakeScale 不工作 - OS X - Cocoa

我正在开发一个简单的 Mac 应用程序。我希望能够在 NSButton 上应用转换并使其更大。它的两倍大小。但是我的代码不起作用,它只是将按钮滑动到角落。有谁知道出了什么问题?

[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {

    [numberButton1.animator.layer setAffineTransform:CGAffineTransformMakeScale(4.0, 4.0)];
    numberButton1.layer.anchorPoint = CGPointMake(0.5, 0.5);
    [numberButton1.animator.layer setAffineTransform:CGAffineTransformMakeScale(1.0, 1.0)];

} completionHandler:nil];
Run Code Online (Sandbox Code Playgroud)

更新 1

我尝试了以下操作,但它没有做任何事情:(

   CGAffineTransform test = CGAffineTransformMakeScale(4.0, 4.0);

   [NSAnimationContext runAnimationGroup:^(NSAnimationContext *ctx) {
        numberButton1.animator.layer.affineTransform = test;
    } completionHandler:^{
        [NSAnimationContext runAnimationGroup:^(NSAnimationContext *ctx) {
            numberButton1.animator.layer.affineTransform = CGAffineTransformIdentity;
        } completionHandler:^{
            NSLog(@"Done...");
        }];
    }];
Run Code Online (Sandbox Code Playgroud)

更新 2

这是我的代码 sudo,希望这会有所帮助:

我的头 (.h) 文件:

#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>

@interface ViewController : NSViewController {

    IBOutlet NSButton *numberButton1;
}

-(IBAction)demo:(id)sender;

@end
Run Code Online (Sandbox Code Playgroud)

我的实现(.m)文件:

#import "ViewController.h"

@implementation ViewController

-(IBAction)demo:(id)sender {

    CGRect …
Run Code Online (Sandbox Code Playgroud)

macos cocoa animation transform nsanimation

0
推荐指数
1
解决办法
1153
查看次数

如何在悬停效果上创建 css translateY

我正在寻找创建一个 CSS 悬停效果,我知道它一定是可能的,但我无法解决它,并且想知道是否有一些明亮的火花能够为我指明正确的方向!

在此处查看此图像,显示我想要实现的目标

因此,图像上方 div 中的某些文本会显示出来,但是当您将鼠标悬停在图像/文本 div 上时,内容会以平滑的方式向上移动

这会与 -webkit-transition translateY 元素一起使用吗?

预先感谢您提供的任何建议或指南!亚当

css transform hover mousehover

0
推荐指数
1
解决办法
5212
查看次数

CSS图像水下效应

因此,我正在尝试使用Css关键帧在某些图像上实现水下效果.我正在使用"transform:skew"来做到这一点,但结果并不是很好,并且看起来并不是有机的.我希望这些图像以流畅的方式移动和扭曲,就好像它们在水下一样.

我的Css:

 @keyframes imgevento{
        0%, 100% {
            transform: skew(0deg, 0deg);

        }
        50% { transform: skew(2deg, 2deg);

        }
    }

    .imgevento{
        transform-origin:50% 50%;
        animation:imgevento 6s linear alternate infinite;
}
Run Code Online (Sandbox Code Playgroud)

无论如何我能用css达到我想要的结果吗?

css animation image transform keyframe

0
推荐指数
1
解决办法
804
查看次数

在 Swift 中制作动画之前,如何将转换应用于 UILabel?

在视图为比例设置动画之前,我希望在没有动画的情况下旋转视图。如果我之后有动画,我现在拥有它的方式会忽略我的初始视图旋转。

label.transform = CGAffineTransform(rotationAngle: CGFloat(90.0 * .pi / 180))

animateLabel(label:label)

func animateLabel(label:UILabel) {

    label.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)

    UIView.animate(withDuration: 0.2, animations: {
        label.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
    },
    completion: { _ in
        UIView.animate(withDuration: 0.1) {
            label.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)

        }
    })

}
Run Code Online (Sandbox Code Playgroud)

更新:我如何用马特的回答更新我的代码,以便它正确动画:

我首先将初始旋转设置为变换变量,然后在调用 animateLabel 时发送它:

var transforms: CGAffineTransform = .identity

transforms = transforms.concatenating(CGAffineTransform(rotationAngle: CGFloat(90.0 * .pi / 180)))

animateLabel(label:label, transforms:transforms)
Run Code Online (Sandbox Code Playgroud)

我连接比例并将变换设置为修改后的变换。然后我可以对实际动画使用缩放比例:

func animateLabel(label:UILabel, transforms:CGAffineTransform) {

    transforms.concatenating(CGAffineTransform(scaleX: 0.6, y: 0.6))

    label.transform = transforms

    UIView.animate(withDuration: 0.2, …
Run Code Online (Sandbox Code Playgroud)

transform rotation uilabel swift

0
推荐指数
1
解决办法
529
查看次数

在 React Native 中,如何水平翻转视图?

假设我有一个这样的图标:

<FontAwesome
    name={'column'}
    size={20}
    style={ /* mirror horizontally */ }
/>
Run Code Online (Sandbox Code Playgroud)

我怎样才能水平镜像?

transform react-native

0
推荐指数
1
解决办法
3929
查看次数